activemq-cpp-3.9.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. More...
 
virtual void stop ()
 Stops this service. More...
 
virtual void close ()
 Closes this object and deallocates the appropriate resources. More...
 
virtual cms::Messagereceive ()
 Synchronously Receive a Message. More...
 
virtual cms::Messagereceive (int millisecs)
 Synchronously Receive a Message, time out after defined interval. More...
 
virtual cms::MessagereceiveNoWait ()
 Receive a Message, does not wait if there isn't a new message to read, returns NULL if nothing read. More...
 
virtual void setMessageListener (cms::MessageListener *listener)
 Sets the MessageListener that this class will send notifs on. More...
 
virtual cms::MessageListenergetMessageListener () const
 Gets the MessageListener that this class will send mew Message notification events to. More...
 
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. More...
 
virtual
cms::MessageAvailableListener
getMessageAvailableListener () const
 Gets the MessageAvailableListener that this class will send mew Message notification events to. More...
 
virtual std::string getMessageSelector () const
 Gets this message consumer's message selector expression. More...
 
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. More...
 
virtual cms::MessageTransformergetMessageTransformer () const
 Gets the currently configured MessageTransformer for this MessageConsumer. More...
 
virtual void dispatch (const Pointer< MessageDispatch > &message)
 Dispatches a message to a particular consumer. More...
 
virtual int getHashCode () const
 HashCode method allowing Dispatcher instances to be used in HashMap etc. More...
 
void acknowledge ()
 Method called to acknowledge all messages that have been received so far. More...
 
void acknowledge (Pointer< commands::MessageDispatch > dispatch)
 Method called to acknowledge the Message contained in the given MessageDispatch. More...
 
void acknowledge (Pointer< commands::MessageDispatch > dispatch, int ackType)
 Method called to acknowledge the Message contained in the given MessageDispatch. More...
 
void commit ()
 Called to Commit the current set of messages in this Transaction. More...
 
void rollback ()
 Called to Roll back the current set of messages in this Transaction. More...
 
void doClose ()
 Performs the actual close operation on this consumer. More...
 
void dispose ()
 Cleans up this objects internal resources. More...
 
const Pointer
< commands::ConsumerInfo > & 
getConsumerInfo () const
 Get the Consumer information for this consumer. More...
 
const Pointer
< commands::ConsumerId > & 
getConsumerId () const
 Get the Consumer Id for this consumer. More...
 
bool isClosed () const
 
bool isSynchronizationRegistered () const
 Has this Consumer Transaction Synchronization been added to the transaction. More...
 
void setSynchronizationRegistered (bool value)
 Sets the Synchronization Registered state of this consumer. More...
 
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. More...
 
void deliverAcks ()
 Forces this consumer to send all pending acks to the broker. More...
 
void clearMessagesInProgress ()
 Called on a Failover to clear any pending messages. More...
 
void inProgressClearRequired ()
 Signals that a Failure occurred and that anything in-progress in the consumer should be cleared. More...
 
long long getLastDeliveredSequenceId () const
 Gets the currently set Last Delivered Sequence Id. More...
 
bool isTransactedIndividualAck () const
 Will Message's in a transaction be acknowledged using the Individual Acknowledge mode. More...
 
void setTransactedIndividualAck (bool value)
 Set if Message's in a transaction be acknowledged using the Individual Acknowledge mode. More...
 
long long setFailoverRedeliveryWaitPeriod () const
 Returns the delay after a failover before Message redelivery starts. More...
 
void setFailoverRedeliveryWaitPeriod (long long value)
 Sets the time in milliseconds to delay after failover before starting message redelivery. More...
 
void setLastDeliveredSequenceId (long long value)
 Sets the value of the Last Delivered Sequence Id. More...
 
int getMessageAvailableCount () const
 
void setRedeliveryPolicy (RedeliveryPolicy *policy)
 Sets the RedeliveryPolicy this Consumer should use when a rollback is performed on a transacted Consumer. More...
 
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. More...
 
void setFailureError (decaf::lang::Exception *error)
 Sets the Exception that has caused this Consumer to be in a failed state. More...
 
decaf::lang::ExceptiongetFailureError () const
 Gets the error that caused this Consumer to be in a Failed state, or NULL if there is no Error. More...
 
void setPrefetchSize (int prefetchSize)
 Sets the current prefetch size for the consumer as indicated by a Broker ConsumerControl command. More...
 
bool isInUse (Pointer< commands::ActiveMQDestination > destination) const
 Checks if the given destination is the Destination that this Consumer is subscribed to. More...
 
long long getOptimizedAckScheduledAckInterval () const
 Time in Milliseconds before an automatic acknowledge is done for any outstanding delivered Messages. More...
 
void setOptimizedAckScheduledAckInterval (long long value)
 Sets the time in Milliseconds to schedule an automatic acknowledge of outstanding messages when optimize acknowledge is enabled. More...
 
bool isOptimizeAcknowledge () const
 
void setOptimizeAcknowledge (bool value)
 Enable or disable optimized acknowledge for this consumer. More...
 
bool isConsumerExpiryCheckEnabled ()
 
void setConsumerExpiryCheckEnabled (bool consumerExpiryCheckEnabled)
 Configures whether this consumer will perform message expiration processing on all incoming messages. More...
 
bool isRedeliveryExpectedInCurrentTransaction (Pointer< commands::MessageDispatch > dispatch) const
 Returns true if the given MessageDispatch is expected to be redelivered in the currently open transaction. More...
 
- 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. More...
 
void beforeMessageIsConsumed (Pointer< commands::MessageDispatch > dispatch)
 Pre-consume processing. More...
 
void afterMessageIsConsumed (Pointer< commands::MessageDispatch > dispatch, bool messageExpired)
 Post-consume processing. More...
 

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

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::acknowledge ( Pointer< commands::MessageDispatch dispatch)

Method called to acknowledge the Message contained in the given MessageDispatch.

Exceptions
CMSExceptionif an error occurs while ack'ing the message.
void activemq::core::kernels::ActiveMQConsumerKernel::acknowledge ( Pointer< commands::MessageDispatch dispatch,
int  ackType 
)

Method called to acknowledge the Message contained in the given MessageDispatch.

Exceptions
CMSExceptionif an error occurs while ack'ing the message.
void activemq::core::kernels::ActiveMQConsumerKernel::afterMessageIsConsumed ( 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 ( 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.
virtual int activemq::core::kernels::ActiveMQConsumerKernel::getHashCode ( ) const
virtual

HashCode method allowing Dispatcher instances to be used in HashMap etc.

Returns
hash value for this Dispatcher.

Implements activemq::core::Dispatcher.

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.

long long activemq::core::kernels::ActiveMQConsumerKernel::getOptimizedAckScheduledAckInterval ( ) const

Time in Milliseconds before an automatic acknowledge is done for any outstanding delivered Messages.

A value less than one means no task is scheduled.

Returns
time in milliseconds for the scheduled ack task.
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::isConsumerExpiryCheckEnabled ( )
Returns
true if the consumer will skip checking messages for expiration.
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::isOptimizeAcknowledge ( ) const
Returns
true if this consumer is using optimize acknowledge mode.
bool activemq::core::kernels::ActiveMQConsumerKernel::isRedeliveryExpectedInCurrentTransaction ( Pointer< commands::MessageDispatch dispatch) const

Returns true if the given MessageDispatch is expected to be redelivered in the currently open transaction.

This would be true for any message that was previously delivered in a transaction and a failover occurred prior to the transaction being completed.

Returns
true if the given dispatch needs to be delivered to this consumer to recover.
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::isTransactedIndividualAck ( ) const

Will Message's in a transaction be acknowledged using the Individual Acknowledge mode.

Returns
true if individual transacted acknowledge is enabled.
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::setConsumerExpiryCheckEnabled ( bool  consumerExpiryCheckEnabled)

Configures whether this consumer will perform message expiration processing on all incoming messages.

This feature is enabled by default.

Parameters
consumerExpiryCheckEnabledFalse if the default message expiration checks should be disabled.
long long activemq::core::kernels::ActiveMQConsumerKernel::setFailoverRedeliveryWaitPeriod ( ) const

Returns the delay after a failover before Message redelivery starts.

Returns
time in milliseconds to wait after failover.
void activemq::core::kernels::ActiveMQConsumerKernel::setFailoverRedeliveryWaitPeriod ( long long  value)

Sets the time in milliseconds to delay after failover before starting message redelivery.

Parameters
valueTime in milliseconds to delay after failover for redelivery start.
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::setOptimizeAcknowledge ( bool  value)

Enable or disable optimized acknowledge for this consumer.

Parameters
valueTrue if optimize acknowledge is enabled, false otherwise.
void activemq::core::kernels::ActiveMQConsumerKernel::setOptimizedAckScheduledAckInterval ( long long  value)

Sets the time in Milliseconds to schedule an automatic acknowledge of outstanding messages when optimize acknowledge is enabled.

A value less than one means disable any scheduled tasks.

Parameters
valueThe time interval to send scheduled acks.
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.
void activemq::core::kernels::ActiveMQConsumerKernel::setTransactedIndividualAck ( bool  value)

Set if Message's in a transaction be acknowledged using the Individual Acknowledge mode.

Parameters
valueTrue if individual transacted acknowledge is enabled.
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: