semaine::cms::receiver::Receiver Class Reference

#include <Receiver.h>

Inheritance diagram for semaine::cms::receiver::Receiver:
semaine::cms::IOBase semaine::cms::receiver::BytesReceiver semaine::cms::receiver::FeatureReceiver semaine::cms::receiver::XMLReceiver semaine::cms::receiver::BMLReceiver semaine::cms::receiver::EmmaReceiver semaine::cms::receiver::FMLReceiver semaine::cms::receiver::StateReceiver

List of all members.

Public Member Functions

 Receiver (const std::string &topicName) throw (CMSException)
 Receiver (const std::string &topicName, const std::string &messageSelector) throw (CMSException)
 Receiver (const std::string &cmsUrl, const std::string &cmsUser, const std::string &cmsPassword, const std::string &topicName) throw (CMSException)
 Receiver (const std::string &cmsUrl, const std::string &cmsUser, const std::string &cmsPassword, const std::string &topicName, const std::string &messageSelector) throw (CMSException)
virtual ~Receiver ()
std::string getMessageSelector () throw (CMSException)
SEMAINEMessagereceive () throw (CMSException, semaine::cms::exceptions::SystemConfigurationException)
SEMAINEMessagereceive (int timeout) throw (CMSException, semaine::cms::exceptions::SystemConfigurationException)
SEMAINEMessagereceiveNoWait () throw (CMSException, semaine::cms::exceptions::SystemConfigurationException)
void setMessageListener (SEMAINEMessageAvailableListener *aListener) throw (CMSException)
SEMAINEMessageAvailableListenergetMessageListener ()
virtual void onMessage (const Message *m)
SEMAINEMessagegetMessage ()
bool notPickedUp ()

Protected Member Functions

virtual SEMAINEMessagecreateSEMAINEMessage (const Message *message) throw (semaine::cms::exceptions::MessageFormatException)

Protected Attributes

MessageConsumer * consumer
SEMAINEMessageAvailableListenerlistener
CMSLoggerlog
SEMAINEMessagemessage
decaf::util::concurrent::Mutex mutex

Detailed Description

This class handles the common part to all message receivers in the SEMAINE system.

Two models of use are possible:

The Receiver itself covers basic text messages only. Subclasses should override createSEMAINEMessage(Message) to do a meaningful analysis of the JMS message in terms of a suitable subclass of SEMAINEMessage.

Author:
marc

Constructor & Destructor Documentation

Receiver::Receiver ( const std::string &  topicName  )  throw (CMSException)

Create a receiver that will listen for all messages in the given Topic on the default JMS server. The default JMS server is determined as follows:

  • jms URL: default value tcp://localhost:61616;
  • jms User: default value empty;
  • jms Password: default value empty.
Parameters:
topic the name of the CMS Topic to listen to.
Receiver::Receiver ( const std::string &  topicName,
const std::string &  messageSelector 
) throw (CMSException)

Create a receiver that will listen only to the messages in the given Topic that will pass the given messageSelector, on the default JMS server. The default JMS server is determined as follows:

  • jms URL: default value tcp://localhost:61616;
  • jms User: default value empty;
  • jms Password: default value empty.
Parameters:
topicName the name of the JMS Topic to listen to.
messageSelector a message selector expression, see e.g. http://java.sun.com/javaee/5/docs/api/javax/jms/Message.html for the detailed description.
Receiver::Receiver ( const std::string &  cmsUrl,
const std::string &  cmsUser,
const std::string &  cmsPassword,
const std::string &  topicName 
) throw (CMSException)

Create a receiver that will listen for all messages in the given Topic on the given JMS server.

Parameters:
cmsUrl the url where to contact the JMS server
cmsUser the username to use (can be an empty string)
cmsPassword the password to use (can be an empty string)
topic the name of the CMS Topic to listen to.
Receiver::Receiver ( const std::string &  cmsUrl,
const std::string &  cmsUser,
const std::string &  cmsPassword,
const std::string &  topicName,
const std::string &  messageSelector 
) throw (CMSException)

Create a receiver that will listen only to the messages in the given Topic that will pass the given messageSelector, on the given JMS server.

Parameters:
cmsUrl the url where to contact the JMS server
cmsUser the username to use (can be an empty string)
cmsPassword the password to use (can be an empty string)
topicName the name of the JMS Topic to listen to.
messageSelector a message selector expression, see e.g. http://java.sun.com/javaee/5/docs/api/javax/jms/Message.html for the detailed description.
Receiver::~Receiver (  )  [virtual]

Member Function Documentation

SEMAINEMessage * Receiver::createSEMAINEMessage ( const Message *  message  )  throw (semaine::cms::exceptions::MessageFormatException) [protected, virtual]

Create a SEMAINE message from the given CMS message. Subclasses may want to override this in order to provide subclasses of SEMAINEMessage for their data.

Parameters:
message the CMS method to convert into a SEMAINE message.
Exceptions:
MessageFormatException if the message format is problematic
NullPointerException if message is null.

Reimplemented in semaine::cms::receiver::BytesReceiver, semaine::cms::receiver::EmmaReceiver, semaine::cms::receiver::FeatureReceiver, semaine::cms::receiver::StateReceiver, and semaine::cms::receiver::XMLReceiver.

SEMAINEMessage * Receiver::getMessage (  ) 
SEMAINEMessageAvailableListener* semaine::cms::receiver::Receiver::getMessageListener (  )  [inline]
std::string semaine::cms::receiver::Receiver::getMessageSelector (  )  throw (CMSException) [inline]

Get the message selector pattern active in this receiver to filter messages.

Returns:
a string representation of the selector pattern.
Exceptions:
CMSException 
bool Receiver::notPickedUp (  ) 
void Receiver::onMessage ( const Message *  m  )  [virtual]
SEMAINEMessage * Receiver::receive ( int  timeout  )  throw (CMSException, semaine::cms::exceptions::SystemConfigurationException)

Receives the next message that arrives within the specified timeout interval. This call blocks until a message arrives, the timeout expires, or this message consumer is closed. A timeout of zero never expires, and the call blocks indefinitely.

Parameters:
timeout the timeout value (in milliseconds)
Returns:
the next message produced for this message consumer, or null if the timeout expires or this message consumer is concurrently closed
Exceptions:
CMSException if the CMS provider fails to receive the next message due to some internal error.
SystemConfigurationException if the connection was not started before calling this method.
SEMAINEMessage * Receiver::receive (  )  throw (CMSException, semaine::cms::exceptions::SystemConfigurationException)

Receives the next message produced for this message consumer. This call blocks indefinitely until a message is produced or until this message consumer is closed.

Returns:
the next message produced for this message consumer, or null if this message consumer is concurrently closed
Exceptions:
CMSException if the CMS provider fails to receive the next message due to some internal error.
SystemConfigurationException if the connection was not started before calling this method.
SEMAINEMessage * Receiver::receiveNoWait (  )  throw (CMSException, semaine::cms::exceptions::SystemConfigurationException)

Receives the next message if one is immediately available.

Returns:
the next message produced for this message consumer, or null if one is not available
Exceptions:
CMSException if the CMS provider fails to receive the next message due to some internal error.
SystemConfigurationException if the connection was not started before calling this method.
void Receiver::setMessageListener ( SEMAINEMessageAvailableListener aListener  )  throw (CMSException)

Member Data Documentation

MessageConsumer* semaine::cms::receiver::Receiver::consumer [protected]
decaf::util::concurrent::Mutex semaine::cms::receiver::Receiver::mutex [protected]

The documentation for this class was generated from the following files:
Generated on Tue Dec 14 17:13:18 2010 for SEMAINE by  doxygen 1.6.3