activemq::core::ActiveMQConsumer Class Reference

#include <ActiveMQConsumer.h>

Inheritance diagram for activemq::core::ActiveMQConsumer:

activemq::core::ActiveMQAckHandler activemq::concurrent::Runnable activemq::core::ActiveMQMessageListener activemq::core::ActiveMQSessionResource List of all members.

Public Member Functions

 ActiveMQConsumer (connector::ConsumerInfo *consumerInfo, ActiveMQSession *session)
virtual ~ActiveMQConsumer (void)
virtual cms::Message * receive (void) throw ( cms::CMSException )
virtual cms::Message * receive (int millisecs) throw ( cms::CMSException )
virtual cms::Message * receiveNoWait (void) throw ( cms::CMSException )
virtual void setMessageListener (cms::MessageListener *listener)
virtual cms::MessageListener * getMessageListener (void) const
virtual std::string getMessageSelector (void) const throw ( cms::CMSException )
virtual void acknowledgeMessage (const ActiveMQMessage *message) throw ( cms::CMSException )
virtual void run (void)
virtual void onActiveMQMessage (ActiveMQMessage *message) throw ( exceptions::ActiveMQException )
virtual connector::ConnectorResourcegetConnectorResource (void)
virtual void dispatch (ActiveMQMessage *message) throw ( cms::CMSException )
virtual connector::ConsumerInfogetConsumerInfo (void)

Protected Member Functions

virtual void purgeMessages (void)
virtual void destroyMessage (cms::Message *message)
void notifyListener (cms::Message *message)
void startThread ()
void stopThread ()

Private Attributes

ActiveMQSessionsession
connector::ConsumerInfoconsumerInfo
cms::MessageListener * listener
concurrent::Mutex listenerLock
util::Queue< cms::Message * > msgQueue
concurrent::ThreadlistenerThread
bool shutdown

Constructor & Destructor Documentation

ActiveMQConsumer::ActiveMQConsumer connector::ConsumerInfo consumerInfo,
ActiveMQSession session
 

Constructor

ActiveMQConsumer::~ActiveMQConsumer void   )  [virtual]
 


Member Function Documentation

void ActiveMQConsumer::acknowledgeMessage const ActiveMQMessage message  )  throw ( cms::CMSException ) [virtual]
 

Method called to acknowledge the message passed

Parameters:
message the Message to Acknowlegde
Exceptions:
CMSException 

Implements activemq::core::ActiveMQAckHandler.

virtual void activemq::core::ActiveMQConsumer::destroyMessage cms::Message *  message  )  [protected, virtual]
 

Destroys the message if the session is transacted, otherwise does nothing.

Parameters:
message the message to destroy

void ActiveMQConsumer::dispatch ActiveMQMessage message  )  throw ( cms::CMSException ) [virtual]
 

Called to dispatch a message to this consumer, this is usually called from the context of another thread. This will enqueue a message on the Consumers Queue, or notify a listener if one is currently registered.

Parameters:
message cms::Message pointer to the message to dispatch
Exceptions:
cms::CMSException 

virtual connector::ConnectorResource* activemq::core::ActiveMQConsumer::getConnectorResource void   )  [inline, virtual]
 

Retrieve the Connector resource that is associated with this Session resource.

Returns:
pointer to a Connector Resource, can be NULL

Implements activemq::core::ActiveMQSessionResource.

virtual connector::ConsumerInfo* activemq::core::ActiveMQConsumer::getConsumerInfo void   )  [inline, virtual]
 

Get the Consumer information for this consumer

Returns:
Pointer to a Consumer Info Object

virtual cms::MessageListener* activemq::core::ActiveMQConsumer::getMessageListener void   )  const [inline, virtual]
 

Gets the MessageListener that this class will send notifs on

Parameters:
MessageListener interface pointer

std::string ActiveMQConsumer::getMessageSelector void   )  const throw ( cms::CMSException ) [virtual]
 

Gets this message consumer's message selector expression.

Returns:
This Consumer's selector expression or "".
Exceptions:
cms::CMSException 

void activemq::core::ActiveMQConsumer::notifyListener cms::Message *  message  )  [protected]
 

Notifies the listener of a message.

Parameters:
message the message to pass to the listener

void ActiveMQConsumer::onActiveMQMessage ActiveMQMessage message  )  throw ( exceptions::ActiveMQException ) [virtual]
 

Called asynchronously when a new message is received, the message that is passed is now the property of the callee, and the caller will disavowe all knowledge of the message, i.e Callee must delete.

Parameters:
message object pointer

Implements activemq::core::ActiveMQMessageListener.

void ActiveMQConsumer::purgeMessages void   )  [protected, virtual]
 

Purges all messages currently in the queue. This can be as a result of a rollback, or of the consumer being shutdown.

cms::Message * ActiveMQConsumer::receive int  millisecs  )  throw ( cms::CMSException ) [virtual]
 

Synchronously Receive a Message, time out after defined interval. Returns null if nothing read.

Parameters:
millisecs the time in milliseconds to wait before returning
Returns:
new message or null on timeout
Exceptions:
CMSException 

cms::Message * ActiveMQConsumer::receive void   )  throw ( cms::CMSException ) [virtual]
 

Synchronously Receive a Message

Returns:
new message
Exceptions:
CMSException 

cms::Message * ActiveMQConsumer::receiveNoWait void   )  throw ( cms::CMSException ) [virtual]
 

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

Returns:
new message
Exceptions:
CMSException 

void ActiveMQConsumer::run void   )  [virtual]
 

Run method that is called from the Thread class when this object is registered with a Thread and started. This function reads from the message queue and dispatches calls to the MessageConsumer that is registered with this class.

It is a error for a MessageListener to throw an exception in their onMessage method, but if it does happen this function will get any registered exception listener from the session and notify it.

Implements activemq::concurrent::Runnable.

void ActiveMQConsumer::setMessageListener cms::MessageListener *  listener  )  [virtual]
 

Sets the MessageListener that this class will send notifs on

Parameters:
listener MessageListener interface pointer

void ActiveMQConsumer::startThread  )  [protected]
 

Starts the message processing thread to receive messages asynchronously. This thread is started when setMessageListener is invoked, which means that the caller is choosing to use this consumer asynchronously instead of synchronously (receive).

void ActiveMQConsumer::stopThread  )  [protected]
 

Stops the asynchronous message processing thread if it's started.


Member Data Documentation

connector::ConsumerInfo* activemq::core::ActiveMQConsumer::consumerInfo [private]
 

cms::MessageListener* activemq::core::ActiveMQConsumer::listener [private]
 

concurrent::Mutex activemq::core::ActiveMQConsumer::listenerLock [private]
 

concurrent::Thread* activemq::core::ActiveMQConsumer::listenerThread [private]
 

util::Queue< cms::Message* > activemq::core::ActiveMQConsumer::msgQueue [private]
 

ActiveMQSession* activemq::core::ActiveMQConsumer::session [private]
 

bool activemq::core::ActiveMQConsumer::shutdown [private]
 


The documentation for this class was generated from the following files:
Generated on Thu Aug 3 18:03:32 2006 for activemq-cpp by  doxygen 1.4.5