activemq-cpp-3.6.0
cms::MessageConsumer Class Reference

A client uses a MessageConsumer to received messages from a destination. More...

#include <src/main/cms/MessageConsumer.h>

Inheritance diagram for cms::MessageConsumer:

Public Member Functions

virtual ~MessageConsumer ()
virtual Messagereceive ()=0
 Synchronously Receive a Message.
virtual Messagereceive (int millisecs)=0
 Synchronously Receive a Message, time out after defined interval.
virtual MessagereceiveNoWait ()=0
 Receive a Message, does not wait if there isn't a new message to read, returns NULL if nothing read.
virtual void setMessageListener (MessageListener *listener)=0
 Sets the MessageListener that this class will send notifs on.
virtual MessageListenergetMessageListener () const =0
 Gets the MessageListener that this class will send mew Message notification events to.
virtual std::string getMessageSelector () const =0
 Gets this message consumer's message selector expression.
virtual void setMessageTransformer (cms::MessageTransformer *transformer)=0
 Set an MessageTransformer instance that is applied to all cms::Message objects before they are dispatched to client code.
virtual cms::MessageTransformergetMessageTransformer () const =0
 Gets the currently configured MessageTransformer for this MessageConsumer.
virtual void setMessageAvailableListener (cms::MessageAvailableListener *listener)=0
 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 =0
 Gets the MessageAvailableListener that this class will send mew Message notification events to.
- Public Member Functions inherited from cms::Closeable
virtual ~Closeable ()
virtual void close ()=0
 Closes this object and deallocates the appropriate resources.
- Public Member Functions inherited from cms::Startable
virtual ~Startable ()
virtual void start ()=0
 Starts the service.
- Public Member Functions inherited from cms::Stoppable
virtual ~Stoppable ()
virtual void stop ()=0
 Stops this service.

Detailed Description

A client uses a MessageConsumer to received messages from a destination.

A client may either synchronously receive a message consumer's messages or have the consumer asynchronously deliver them as they arrive.

For synchronous receipt, a client can request the next message from a message consumer using one of its receive methods. There are several variations of receive that allow a client to poll or wait for the next message.

For asynchronous delivery, a client can register a MessageListener object with a message consumer. As messages arrive at the message consumer, it delivers them by calling the MessageListener's onMessage method.

When the MessageConsumer's close method is called the method can block while an asynchronous message delivery is in progress or until a receive operation completes. A blocked consumer in a receive call will return a Null when the close method is called.

While the MessageConsumer implements the Startable and Stoppable interfaces it is not required to implement these methods and can throw an UnsupportedOperation exception if they are not available for the given CMS provider.

See Also
MessageListener
Since
1.0

Constructor & Destructor Documentation

virtual cms::MessageConsumer::~MessageConsumer ( )
virtual

Member Function Documentation

virtual cms::MessageAvailableListener* cms::MessageConsumer::getMessageAvailableListener ( ) const
pure 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.

Implemented in activemq::core::kernels::ActiveMQConsumerKernel, activemq::cmsutil::CachedConsumer, and activemq::core::ActiveMQConsumer.

Referenced by activemq::cmsutil::CachedConsumer::getMessageAvailableListener().

virtual MessageListener* cms::MessageConsumer::getMessageListener ( ) const
pure 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.

Implemented in activemq::core::kernels::ActiveMQConsumerKernel, activemq::core::ActiveMQConsumer, and activemq::cmsutil::CachedConsumer.

Referenced by activemq::cmsutil::CachedConsumer::getMessageListener().

virtual std::string cms::MessageConsumer::getMessageSelector ( ) const
pure virtual

Gets this message consumer's message selector expression.

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

Implemented in activemq::core::kernels::ActiveMQConsumerKernel, activemq::core::ActiveMQConsumer, and activemq::cmsutil::CachedConsumer.

Referenced by activemq::cmsutil::CachedConsumer::getMessageSelector().

virtual cms::MessageTransformer* cms::MessageConsumer::getMessageTransformer ( ) const
pure virtual
virtual Message* cms::MessageConsumer::receive ( )
pure virtual

Synchronously Receive a Message.

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

Implemented in activemq::core::kernels::ActiveMQConsumerKernel, activemq::core::ActiveMQConsumer, and activemq::cmsutil::CachedConsumer.

Referenced by activemq::cmsutil::CachedConsumer::receive().

virtual Message* cms::MessageConsumer::receive ( int  millisecs)
pure 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.

Implemented in activemq::core::kernels::ActiveMQConsumerKernel, activemq::core::ActiveMQConsumer, and activemq::cmsutil::CachedConsumer.

virtual Message* cms::MessageConsumer::receiveNoWait ( )
pure 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.

Implemented in activemq::core::kernels::ActiveMQConsumerKernel, activemq::core::ActiveMQConsumer, and activemq::cmsutil::CachedConsumer.

Referenced by activemq::cmsutil::CachedConsumer::receiveNoWait().

virtual void cms::MessageConsumer::setMessageAvailableListener ( cms::MessageAvailableListener listener)
pure 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.

Implemented in activemq::core::kernels::ActiveMQConsumerKernel, activemq::cmsutil::CachedConsumer, and activemq::core::ActiveMQConsumer.

Referenced by activemq::cmsutil::CachedConsumer::setMessageAvailableListener().

virtual void cms::MessageConsumer::setMessageListener ( MessageListener listener)
pure 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.

Implemented in activemq::core::kernels::ActiveMQConsumerKernel, activemq::core::ActiveMQConsumer, and activemq::cmsutil::CachedConsumer.

Referenced by activemq::cmsutil::CachedConsumer::setMessageListener().

virtual void cms::MessageConsumer::setMessageTransformer ( cms::MessageTransformer transformer)
pure 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.

Implemented in activemq::core::kernels::ActiveMQConsumerKernel, activemq::cmsutil::CachedConsumer, and activemq::core::ActiveMQConsumer.

Referenced by activemq::cmsutil::CachedConsumer::setMessageTransformer().


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