activemq-cpp-3.6.0
activemq::core::kernels::ActiveMQConsumerKernel Class Reference

#include <src/main/activemq/core/kernels/ActiveMQConsumerKernel.h>

Inheritance diagram for activemq::core::kernels::ActiveMQConsumerKernel:

Public Member Functions

 ActiveMQConsumerKernel (ActiveMQSessionKernel *session, const Pointer< commands::ConsumerId > &id, const Pointer< commands::ActiveMQDestination > &destination, const std::string &name, const std::string &selector, int prefetch, int maxPendingMessageCount, bool noLocal, bool browser, bool dispatchAsync, cms::MessageListener *listener)
virtual ~ActiveMQConsumerKernel ()
virtual void start ()
 Starts the service.
virtual void stop ()
 Stops this service.
virtual void close ()
 Closes this object and deallocates the appropriate resources.
virtual cms::Messagereceive ()
 Synchronously Receive a Message.
virtual cms::Messagereceive (int millisecs)
 Synchronously Receive a Message, time out after defined interval.
virtual cms::MessagereceiveNoWait ()
 Receive a Message, does not wait if there isn't a new message to read, returns NULL if nothing read.
virtual void setMessageListener (cms::MessageListener *listener)
 Sets the MessageListener that this class will send notifs on.
virtual cms::MessageListenergetMessageListener () const
 Gets the MessageListener that this class will send mew Message notification events to.
virtual void setMessageAvailableListener (cms::MessageAvailableListener *listener)
 Sets the MessageAvailableListener that this class will send events to if the consumer is in synchronous consumption mode and a new Message has arrived.
virtual
cms::MessageAvailableListener
getMessageAvailableListener () const
 Gets the MessageAvailableListener that this class will send mew Message notification events to.
virtual std::string getMessageSelector () const
 Gets this message consumer's message selector expression.
virtual void acknowledge (const Pointer< commands::MessageDispatch > &dispatch)
virtual void setMessageTransformer (cms::MessageTransformer *transformer)
 Set an MessageTransformer instance that is applied to all cms::Message objects before they are dispatched to client code.
virtual cms::MessageTransformergetMessageTransformer () const
 Gets the currently configured MessageTransformer for this MessageConsumer.
virtual void dispatch (const Pointer< MessageDispatch > &message)
 Dispatches a message to a particular consumer.
void acknowledge ()
 Method called to acknowledge all messages that have been received so far.
void commit ()
 Called to Commit the current set of messages in this Transaction.
void rollback ()
 Called to Roll back the current set of messages in this Transaction.
void doClose ()
 Performs the actual close operation on this consumer.
void dispose ()
 Cleans up this objects internal resources.
const Pointer
< commands::ConsumerInfo > & 
getConsumerInfo () const
 Get the Consumer information for this consumer.
const Pointer
< commands::ConsumerId > & 
getConsumerId () const
 Get the Consumer Id for this consumer.
bool isClosed () const
bool isSynchronizationRegistered () const
 Has this Consumer Transaction Synchronization been added to the transaction.
void setSynchronizationRegistered (bool value)
 Sets the Synchronization Registered state of this consumer.
bool iterate ()
 Deliver any pending messages to the registered MessageListener if there is one, return true if not all dispatched, or false if no listener or all pending messages have been dispatched.
void deliverAcks ()
 Forces this consumer to send all pending acks to the broker.
void clearMessagesInProgress ()
 Called on a Failover to clear any pending messages.
void inProgressClearRequired ()
 Signals that a Failure occurred and that anything in-progress in the consumer should be cleared.
long long getLastDeliveredSequenceId () const
 Gets the currently set Last Delivered Sequence Id.
void setLastDeliveredSequenceId (long long value)
 Sets the value of the Last Delivered Sequence Id.
int getMessageAvailableCount () const
void setRedeliveryPolicy (RedeliveryPolicy *policy)
 Sets the RedeliveryPolicy this Consumer should use when a rollback is performed on a transacted Consumer.
RedeliveryPolicygetRedeliveryPolicy () const
 Gets a pointer to this Consumer's Redelivery Policy object, the Consumer retains ownership of this pointer so the caller should not delete it.
void setFailureError (decaf::lang::Exception *error)
 Sets the Exception that has caused this Consumer to be in a failed state.
decaf::lang::ExceptiongetFailureError () const
 Gets the error that caused this Consumer to be in a Failed state, or NULL if there is no Error.
void setPrefetchSize (int prefetchSize)
 Sets the current prefetch size for the consumer as indicated by a Broker ConsumerControl command.
bool isInUse (Pointer< commands::ActiveMQDestination > destination) const
 Checks if the given destination is the Destination that this Consumer is subscribed to.
- Public Member Functions inherited from cms::MessageConsumer
virtual ~MessageConsumer ()
- Public Member Functions inherited from cms::Closeable
virtual ~Closeable ()
- Public Member Functions inherited from cms::Startable
virtual ~Startable ()
- Public Member Functions inherited from cms::Stoppable
virtual ~Stoppable ()
- Public Member Functions inherited from activemq::core::Dispatcher
virtual ~Dispatcher ()

Protected Member Functions

Pointer< MessageDispatchdequeue (long long timeout)
 Used by synchronous receive methods to wait for messages to come in.
void beforeMessageIsConsumed (const Pointer< commands::MessageDispatch > &dispatch)
 Pre-consume processing.
void afterMessageIsConsumed (const Pointer< commands::MessageDispatch > &dispatch, bool messageExpired)
 Post-consume processing.

Constructor & Destructor Documentation

activemq::core::kernels::ActiveMQConsumerKernel::ActiveMQConsumerKernel ( ActiveMQSessionKernel session,
const Pointer< commands::ConsumerId > &  id,
const Pointer< commands::ActiveMQDestination > &  destination,
const std::string &  name,
const std::string &  selector,
int  prefetch,
int  maxPendingMessageCount,
bool  noLocal,
bool  browser,
bool  dispatchAsync,
cms::MessageListener listener 
)
virtual activemq::core::kernels::ActiveMQConsumerKernel::~ActiveMQConsumerKernel ( )
virtual

Member Function Documentation

virtual void activemq::core::kernels::ActiveMQConsumerKernel::acknowledge ( const Pointer< commands::MessageDispatch > &  dispatch)
virtual
void activemq::core::kernels::ActiveMQConsumerKernel::acknowledge ( )

Method called to acknowledge all messages that have been received so far.

Exceptions
CMSExceptionif an error occurs while ack'ing the message.
void activemq::core::kernels::ActiveMQConsumerKernel::afterMessageIsConsumed ( const Pointer< commands::MessageDispatch > &  dispatch,
bool  messageExpired 
)
protected

Post-consume processing.

Parameters
dispatch- the consumed message
messageExpired- flag indicating if the message has expired.
void activemq::core::kernels::ActiveMQConsumerKernel::beforeMessageIsConsumed ( const Pointer< commands::MessageDispatch > &  dispatch)
protected

Pre-consume processing.

Parameters
dispatch- the message being consumed.
void activemq::core::kernels::ActiveMQConsumerKernel::clearMessagesInProgress ( )

Called on a Failover to clear any pending messages.

virtual void activemq::core::kernels::ActiveMQConsumerKernel::close ( )
virtual

Closes this object and deallocates the appropriate resources.

The object is generally no longer usable after calling close.

Exceptions
CMSException- If an error occurs while the resource is being closed.

Implements cms::Closeable.

void activemq::core::kernels::ActiveMQConsumerKernel::commit ( )

Called to Commit the current set of messages in this Transaction.

Exceptions
ActiveMQExceptionif an error occurs while performing the operation.
void activemq::core::kernels::ActiveMQConsumerKernel::deliverAcks ( )

Forces this consumer to send all pending acks to the broker.

Exceptions
ActiveMQExceptionif an error occurs while performing the operation.
Pointer<MessageDispatch> activemq::core::kernels::ActiveMQConsumerKernel::dequeue ( long long  timeout)
protected

Used by synchronous receive methods to wait for messages to come in.

Parameters
timeout- The maximum number of milliseconds to wait before returning.

If -1, it will block until a messages is received or this consumer is closed. If 0, will not block at all. If > 0, will wait at a maximum the specified number of milliseconds before returning.

Returns
the message, if received within the allotted time. Otherwise NULL.
Exceptions
InvalidStateExceptionif this consumer is closed upon entering this method.
virtual void activemq::core::kernels::ActiveMQConsumerKernel::dispatch ( const Pointer< MessageDispatch > &  message)
virtual

Dispatches a message to a particular consumer.

Parameters
messageThe message to be dispatched to a waiting consumer.

Implements activemq::core::Dispatcher.

void activemq::core::kernels::ActiveMQConsumerKernel::dispose ( )

Cleans up this objects internal resources.

Exceptions
ActiveMQExceptionif an error occurs while performing the operation.
void activemq::core::kernels::ActiveMQConsumerKernel::doClose ( )

Performs the actual close operation on this consumer.

Exceptions
ActiveMQExceptionif an error occurs while performing the operation.
const Pointer<commands::ConsumerId>& activemq::core::kernels::ActiveMQConsumerKernel::getConsumerId ( ) const

Get the Consumer Id for this consumer.

Returns
Reference to a Consumer Id Object
const Pointer<commands::ConsumerInfo>& activemq::core::kernels::ActiveMQConsumerKernel::getConsumerInfo ( ) const

Get the Consumer information for this consumer.

Returns
Reference to a Consumer Info Object
decaf::lang::Exception* activemq::core::kernels::ActiveMQConsumerKernel::getFailureError ( ) const

Gets the error that caused this Consumer to be in a Failed state, or NULL if there is no Error.

Returns
pointer to the error that faulted this Consumer or NULL.
long long activemq::core::kernels::ActiveMQConsumerKernel::getLastDeliveredSequenceId ( ) const

Gets the currently set Last Delivered Sequence Id.

Returns
long long containing the sequence id of the last delivered Message.
int activemq::core::kernels::ActiveMQConsumerKernel::getMessageAvailableCount ( ) const
Returns
the number of Message's this consumer is waiting to Dispatch.
virtual cms::MessageAvailableListener* activemq::core::kernels::ActiveMQConsumerKernel::getMessageAvailableListener ( ) const
virtual

Gets the MessageAvailableListener that this class will send mew Message notification events to.

Returns
The listener of message events received by this consumer.
Exceptions
CMSException- If an internal error occurs.

Implements cms::MessageConsumer.

virtual cms::MessageListener* activemq::core::kernels::ActiveMQConsumerKernel::getMessageListener ( ) const
virtual

Gets the MessageListener that this class will send mew Message notification events to.

Returns
The listener of messages received by this consumer
Exceptions
CMSException- If an internal error occurs.

Implements cms::MessageConsumer.

virtual std::string activemq::core::kernels::ActiveMQConsumerKernel::getMessageSelector ( ) const
virtual

Gets this message consumer's message selector expression.

Returns
This Consumer's selector expression or "".
Exceptions
CMSException- If an internal error occurs.

Implements cms::MessageConsumer.

virtual cms::MessageTransformer* activemq::core::kernels::ActiveMQConsumerKernel::getMessageTransformer ( ) const
virtual

Gets the currently configured MessageTransformer for this MessageConsumer.

Returns
the pointer to the currently set cms::MessageTransformer.

Implements cms::MessageConsumer.

RedeliveryPolicy* activemq::core::kernels::ActiveMQConsumerKernel::getRedeliveryPolicy ( ) const

Gets a pointer to this Consumer's Redelivery Policy object, the Consumer retains ownership of this pointer so the caller should not delete it.

Returns
a Pointer to a RedeliveryPolicy that is in use by this Consumer.
void activemq::core::kernels::ActiveMQConsumerKernel::inProgressClearRequired ( )

Signals that a Failure occurred and that anything in-progress in the consumer should be cleared.

bool activemq::core::kernels::ActiveMQConsumerKernel::isClosed ( ) const
Returns
if this Consumer has been closed.
bool activemq::core::kernels::ActiveMQConsumerKernel::isInUse ( Pointer< commands::ActiveMQDestination destination) const

Checks if the given destination is the Destination that this Consumer is subscribed to.

Returns
true if the consumer is subscribed to the given destination.
bool activemq::core::kernels::ActiveMQConsumerKernel::isSynchronizationRegistered ( ) const

Has this Consumer Transaction Synchronization been added to the transaction.

Returns
true if the synchronization has been added.
bool activemq::core::kernels::ActiveMQConsumerKernel::iterate ( )

Deliver any pending messages to the registered MessageListener if there is one, return true if not all dispatched, or false if no listener or all pending messages have been dispatched.

virtual cms::Message* activemq::core::kernels::ActiveMQConsumerKernel::receive ( )
virtual

Synchronously Receive a Message.

Returns
new message which the caller owns and must delete.
Exceptions
CMSException- If an internal error occurs.

Implements cms::MessageConsumer.

virtual cms::Message* activemq::core::kernels::ActiveMQConsumerKernel::receive ( int  millisecs)
virtual

Synchronously Receive a Message, time out after defined interval.

Returns null if nothing read.

Returns
new message which the caller owns and must delete.
Exceptions
CMSException- If an internal error occurs.

Implements cms::MessageConsumer.

virtual cms::Message* activemq::core::kernels::ActiveMQConsumerKernel::receiveNoWait ( )
virtual

Receive a Message, does not wait if there isn't a new message to read, returns NULL if nothing read.

Returns
new message which the caller owns and must delete.
Exceptions
CMSException- If an internal error occurs.

Implements cms::MessageConsumer.

void activemq::core::kernels::ActiveMQConsumerKernel::rollback ( )

Called to Roll back the current set of messages in this Transaction.

Exceptions
ActiveMQExceptionif an error occurs while performing the operation.
void activemq::core::kernels::ActiveMQConsumerKernel::setFailureError ( decaf::lang::Exception error)

Sets the Exception that has caused this Consumer to be in a failed state.

Parameters
errorThe error that is to be thrown when a Receive call is made.
void activemq::core::kernels::ActiveMQConsumerKernel::setLastDeliveredSequenceId ( long long  value)

Sets the value of the Last Delivered Sequence Id.

Parameters
valueThe new value to assign to the Last Delivered Sequence Id property.
virtual void activemq::core::kernels::ActiveMQConsumerKernel::setMessageAvailableListener ( cms::MessageAvailableListener listener)
virtual

Sets the MessageAvailableListener that this class will send events to if the consumer is in synchronous consumption mode and a new Message has arrived.

Parameters
listenerThe listener of new message events fired by this consumer.
Exceptions
CMSException- If an internal error occurs.

Implements cms::MessageConsumer.

virtual void activemq::core::kernels::ActiveMQConsumerKernel::setMessageListener ( cms::MessageListener listener)
virtual

Sets the MessageListener that this class will send notifs on.

Parameters
listenerThe listener of messages received by this consumer.
Exceptions
CMSException- If an internal error occurs.

Implements cms::MessageConsumer.

virtual void activemq::core::kernels::ActiveMQConsumerKernel::setMessageTransformer ( cms::MessageTransformer transformer)
virtual

Set an MessageTransformer instance that is applied to all cms::Message objects before they are dispatched to client code.

The CMS code never takes ownership of the MessageTransformer pointer which implies that the client code must ensure that the object remains valid for the lifetime of the CMS object to which the MessageTransformer has been assigned.

Parameters
transformerPointer to the cms::MessageTransformer to apply on each cms:;Message dispatch.

Implements cms::MessageConsumer.

void activemq::core::kernels::ActiveMQConsumerKernel::setPrefetchSize ( int  prefetchSize)

Sets the current prefetch size for the consumer as indicated by a Broker ConsumerControl command.

void activemq::core::kernels::ActiveMQConsumerKernel::setRedeliveryPolicy ( RedeliveryPolicy policy)

Sets the RedeliveryPolicy this Consumer should use when a rollback is performed on a transacted Consumer.

The Consumer takes ownership of the passed pointer. The Consumer's redelivery policy can never be null, a call to this method with a NULL pointer is ignored.

Parameters
policyPointer to a Redelivery Policy object that his Consumer will use.
void activemq::core::kernels::ActiveMQConsumerKernel::setSynchronizationRegistered ( bool  value)

Sets the Synchronization Registered state of this consumer.

Parameters
value- true if registered false otherwise.
virtual void activemq::core::kernels::ActiveMQConsumerKernel::start ( )
virtual

Starts the service.

Exceptions
CMSExceptionif an internal error occurs while starting.

Implements cms::Startable.

virtual void activemq::core::kernels::ActiveMQConsumerKernel::stop ( )
virtual

Stops this service.

Exceptions
CMSException- if an internal error occurs while stopping the Service.

Implements cms::Stoppable.


The documentation for this class was generated from the following file: