activemq-cpp-3.4.0
|
CmsTemplate
simplifies performing synchronous CMS operations.
More...
#include <src/main/activemq/cmsutil/CmsTemplate.h>
Data Structures | |
class | ProducerExecutor |
class | ReceiveExecutor |
class | ResolveProducerExecutor |
class | ResolveReceiveExecutor |
class | SendExecutor |
Public Member Functions | |
CmsTemplate () | |
CmsTemplate (cms::ConnectionFactory *connectionFactory) | |
virtual | ~CmsTemplate () throw () |
virtual void | setDefaultDestination (cms::Destination *defaultDestination) |
Sets the destination object to be used by default for send/receive operations. | |
virtual const cms::Destination * | getDefaultDestination () const |
Retrieves the default destination to be used for send/receive operations. | |
virtual cms::Destination * | getDefaultDestination () |
Retrieves the default destination to be used for send/receive operations. | |
virtual void | setDefaultDestinationName (const std::string &defaultDestinationName) |
Sets the name of the default destination to be used from send/receive operations. | |
virtual const std::string | getDefaultDestinationName () const |
Gets the name of the default destination to be used for send/receive operations. | |
virtual void | setPubSubDomain (bool pubSubDomain) |
Indicates whether the default destination is a topic (true) or a queue (false). | |
virtual void | setMessageIdEnabled (bool messageIdEnabled) |
virtual bool | isMessageIdEnabled () const |
virtual void | setMessageTimestampEnabled (bool messageTimestampEnabled) |
virtual bool | isMessageTimestampEnabled () const |
virtual void | setNoLocal (bool noLocal) |
virtual bool | isNoLocal () const |
virtual void | setReceiveTimeout (long long receiveTimeout) |
virtual long long | getReceiveTimeout () const |
virtual void | setExplicitQosEnabled (bool explicitQosEnabled) |
Set if the QOS values (deliveryMode, priority, timeToLive) should be used for sending a message. | |
virtual bool | isExplicitQosEnabled () const |
If "true", then the values of deliveryMode, priority, and timeToLive will be used when sending a message. | |
virtual void | setDeliveryPersistent (bool deliveryPersistent) |
Set whether message delivery should be persistent or non-persistent, specified as boolean value ("true" or "false"). | |
virtual void | setDeliveryMode (int deliveryMode) |
Set the delivery mode to use when sending a message. | |
virtual int | getDeliveryMode () const |
Return the delivery mode to use when sending a message. | |
virtual void | setPriority (int priority) |
Set the priority of a message when sending. | |
virtual int | getPriority () const |
Return the priority of a message when sending. | |
virtual void | setTimeToLive (long long timeToLive) |
Set the time-to-live of the message when sending. | |
virtual long long | getTimeToLive () const |
Return the time-to-live of the message when sending. | |
virtual void | execute (SessionCallback *action) |
Executes the given action within a CMS Session. | |
virtual void | execute (ProducerCallback *action) |
Executes the given action and provides it with a CMS Session and producer. | |
virtual void | execute (cms::Destination *dest, ProducerCallback *action) |
Executes the given action and provides it with a CMS Session and producer. | |
virtual void | execute (const std::string &destinationName, ProducerCallback *action) |
Executes the given action and provides it with a CMS Session and producer. | |
virtual void | send (MessageCreator *messageCreator) |
Convenience method for sending a message to the default destination. | |
virtual void | send (cms::Destination *dest, MessageCreator *messageCreator) |
Convenience method for sending a message to the specified destination. | |
virtual void | send (const std::string &destinationName, MessageCreator *messageCreator) |
Convenience method for sending a message to the specified destination. | |
virtual cms::Message * | receive () |
Performs a synchronous read from the default destination. | |
virtual cms::Message * | receive (cms::Destination *destination) |
Performs a synchronous read from the specified destination. | |
virtual cms::Message * | receive (const std::string &destinationName) |
Performs a synchronous read from the specified destination. | |
virtual cms::Message * | receiveSelected (const std::string &selector) |
Performs a synchronous read consuming only messages identified by the given selector. | |
virtual cms::Message * | receiveSelected (cms::Destination *destination, const std::string &selector) |
Performs a synchronous read from the specified destination, consuming only messages identified by the given selector. | |
virtual cms::Message * | receiveSelected (const std::string &destinationName, const std::string &selector) |
Performs a synchronous read from the specified destination, consuming only messages identified by the given selector. | |
Static Public Attributes | |
static const long long | RECEIVE_TIMEOUT_NO_WAIT |
Timeout value indicating that a receive operation should check if a message is immediately available without blocking. | |
static const long long | RECEIVE_TIMEOUT_INDEFINITE_WAIT |
Timeout value indicating a blocking receive without timeout. | |
static const int | DEFAULT_PRIORITY |
Default message priority. | |
static const long long | DEFAULT_TIME_TO_LIVE |
My default, messages should live forever. | |
Protected Member Functions | |
void | init () |
Initializes this object and prepares it for use. | |
void | destroy () |
Shuts down this object and destroys any allocated resources. | |
Friends | |
class | ProducerExecutor |
class | ResolveProducerExecutor |
class | SendExecutor |
class | ReceiveExecutor |
class | ResolveReceiveExecutor |
CmsTemplate
simplifies performing synchronous CMS operations.
This class is intended to be for CMS what Spring's JmsTemplate
is for JMS. Provided with a CMS ConnectionFactory
, creates and manages all other CMS resources internally.
Before using CmsTemplate
the user must first set the destination (either by name or by setting the destination object directly) and then call init
to initialize the object for use.
CmsTemplate
allows the user to get access to a CMS Session
through a user-defined SessionCallback
. Similarly, if the user wants direct access to a CMS MessageProducer
, it can provide a ProducerCallback
. As a convenience, the user can bypass having to provide callbacks altogether for sending messages, by calling one of the send
methods.
activemq::cmsutil::CmsTemplate::CmsTemplate | ( | ) |
activemq::cmsutil::CmsTemplate::CmsTemplate | ( | cms::ConnectionFactory * | connectionFactory | ) |
virtual activemq::cmsutil::CmsTemplate::~CmsTemplate | ( | ) | throw () [virtual] |
void activemq::cmsutil::CmsTemplate::destroy | ( | ) | [protected, virtual] |
Shuts down this object and destroys any allocated resources.
CMSException | if an error occurs during destruction. |
IllegalStateException | if this object has already been destroyed. |
Reimplemented from activemq::cmsutil::CmsDestinationAccessor.
virtual void activemq::cmsutil::CmsTemplate::execute | ( | SessionCallback * | action | ) | [virtual] |
Executes the given action within a CMS Session.
action | the action to perform within a CMS Session |
cms::CMSException | thrown if an error occurs. |
virtual void activemq::cmsutil::CmsTemplate::execute | ( | ProducerCallback * | action | ) | [virtual] |
Executes the given action and provides it with a CMS Session and producer.
action | the action to perform |
cms::CMSException | thrown if an error occurs. |
virtual void activemq::cmsutil::CmsTemplate::execute | ( | cms::Destination * | dest, |
ProducerCallback * | action | ||
) | [virtual] |
Executes the given action and provides it with a CMS Session and producer.
dest | the destination to send messages to |
action | the action to perform |
cms::CMSException | thrown if an error occurs. |
virtual void activemq::cmsutil::CmsTemplate::execute | ( | const std::string & | destinationName, |
ProducerCallback * | action | ||
) | [virtual] |
Executes the given action and provides it with a CMS Session and producer.
destinationName | the name of the destination to send messages to (to internally be resolved to an actual destination) |
action | the action to perform |
cms::CMSException | thrown if an error occurs. |
virtual cms::Destination* activemq::cmsutil::CmsTemplate::getDefaultDestination | ( | ) | [inline, virtual] |
Retrieves the default destination to be used for send/receive operations.
virtual const cms::Destination* activemq::cmsutil::CmsTemplate::getDefaultDestination | ( | ) | const [inline, virtual] |
Retrieves the default destination to be used for send/receive operations.
virtual const std::string activemq::cmsutil::CmsTemplate::getDefaultDestinationName | ( | ) | const [inline, virtual] |
Gets the name of the default destination to be used for send/receive operations.
The destination type (topic/queue) is determined by the pubSubDomain
property.
virtual int activemq::cmsutil::CmsTemplate::getDeliveryMode | ( | ) | const [inline, virtual] |
Return the delivery mode to use when sending a message.
virtual int activemq::cmsutil::CmsTemplate::getPriority | ( | ) | const [inline, virtual] |
Return the priority of a message when sending.
virtual long long activemq::cmsutil::CmsTemplate::getReceiveTimeout | ( | ) | const [inline, virtual] |
virtual long long activemq::cmsutil::CmsTemplate::getTimeToLive | ( | ) | const [inline, virtual] |
Return the time-to-live of the message when sending.
void activemq::cmsutil::CmsTemplate::init | ( | ) | [protected, virtual] |
Initializes this object and prepares it for use.
This should be called before any other methods are called. This version does nothing.
CMSException | if an error occurs during initialization. |
IllegalStateException | if this object has already been initialized. |
Reimplemented from activemq::cmsutil::CmsDestinationAccessor.
virtual bool activemq::cmsutil::CmsTemplate::isExplicitQosEnabled | ( | ) | const [inline, virtual] |
If "true", then the values of deliveryMode, priority, and timeToLive will be used when sending a message.
Otherwise, the default values, that may be set administratively, will be used.
virtual bool activemq::cmsutil::CmsTemplate::isMessageIdEnabled | ( | ) | const [inline, virtual] |
virtual bool activemq::cmsutil::CmsTemplate::isMessageTimestampEnabled | ( | ) | const [inline, virtual] |
virtual bool activemq::cmsutil::CmsTemplate::isNoLocal | ( | ) | const [inline, virtual] |
virtual cms::Message* activemq::cmsutil::CmsTemplate::receive | ( | cms::Destination * | destination | ) | [virtual] |
Performs a synchronous read from the specified destination.
destination | the destination to receive on |
cms::CMSException | thrown if an error occurs |
virtual cms::Message* activemq::cmsutil::CmsTemplate::receive | ( | const std::string & | destinationName | ) | [virtual] |
Performs a synchronous read from the specified destination.
destinationName | the name of the destination to receive on (will be resolved to destination internally). |
cms::CMSException | thrown if an error occurs |
virtual cms::Message* activemq::cmsutil::CmsTemplate::receive | ( | ) | [virtual] |
Performs a synchronous read from the default destination.
cms::CMSException | thrown if an error occurs |
virtual cms::Message* activemq::cmsutil::CmsTemplate::receiveSelected | ( | const std::string & | selector | ) | [virtual] |
Performs a synchronous read consuming only messages identified by the given selector.
selector | the selector expression. |
cms::CMSException | thrown if an error occurs |
virtual cms::Message* activemq::cmsutil::CmsTemplate::receiveSelected | ( | cms::Destination * | destination, |
const std::string & | selector | ||
) | [virtual] |
Performs a synchronous read from the specified destination, consuming only messages identified by the given selector.
destination | the destination to receive on. |
selector | the selector expression. |
cms::CMSException | thrown if an error occurs |
virtual cms::Message* activemq::cmsutil::CmsTemplate::receiveSelected | ( | const std::string & | destinationName, |
const std::string & | selector | ||
) | [virtual] |
Performs a synchronous read from the specified destination, consuming only messages identified by the given selector.
destinationName | the name of the destination to receive on (will be resolved to destination internally). |
selector | the selector expression. |
cms::CMSException | thrown if an error occurs |
virtual void activemq::cmsutil::CmsTemplate::send | ( | cms::Destination * | dest, |
MessageCreator * | messageCreator | ||
) | [virtual] |
Convenience method for sending a message to the specified destination.
dest | The destination to send to |
messageCreator | Responsible for creating the message to be sent |
cms::CMSException | thrown if an error occurs. |
virtual void activemq::cmsutil::CmsTemplate::send | ( | const std::string & | destinationName, |
MessageCreator * | messageCreator | ||
) | [virtual] |
Convenience method for sending a message to the specified destination.
destinationName | The name of the destination to send to. |
messageCreator | Responsible for creating the message to be sent |
cms::CMSException | thrown if an error occurs. |
virtual void activemq::cmsutil::CmsTemplate::send | ( | MessageCreator * | messageCreator | ) | [virtual] |
Convenience method for sending a message to the default destination.
messageCreator | Responsible for creating the message to be sent |
cms::CMSException | thrown if an error occurs. |
virtual void activemq::cmsutil::CmsTemplate::setDefaultDestination | ( | cms::Destination * | defaultDestination | ) | [inline, virtual] |
Sets the destination object to be used by default for send/receive operations.
If no default destination is provided, the defaultDestinationName
property is used to resolve this default destination for send/receive operations.
defaultDestination | the default destination |
virtual void activemq::cmsutil::CmsTemplate::setDefaultDestinationName | ( | const std::string & | defaultDestinationName | ) | [inline, virtual] |
Sets the name of the default destination to be used from send/receive operations.
Calling this method will set the defaultDestination
property to NULL. The destination type (topic/queue) is determined by the pubSubDomain
property.
defaultDestinationName | the name of the destination for send/receive to by default. |
virtual void activemq::cmsutil::CmsTemplate::setDeliveryMode | ( | int | deliveryMode | ) | [inline, virtual] |
Set the delivery mode to use when sending a message.
Default is the Message default: "PERSISTENT".
Since a default value may be defined administratively, this is only used when "isExplicitQosEnabled" equals "true".
deliveryMode | the delivery mode to use |
virtual void activemq::cmsutil::CmsTemplate::setDeliveryPersistent | ( | bool | deliveryPersistent | ) | [inline, virtual] |
Set whether message delivery should be persistent or non-persistent, specified as boolean value ("true" or "false").
This will set the delivery mode accordingly, to either "PERSISTENT" or "NON_PERSISTENT".
Default it "true" aka delivery mode "PERSISTENT".
virtual void activemq::cmsutil::CmsTemplate::setExplicitQosEnabled | ( | bool | explicitQosEnabled | ) | [inline, virtual] |
Set if the QOS values (deliveryMode, priority, timeToLive) should be used for sending a message.
virtual void activemq::cmsutil::CmsTemplate::setMessageIdEnabled | ( | bool | messageIdEnabled | ) | [inline, virtual] |
virtual void activemq::cmsutil::CmsTemplate::setMessageTimestampEnabled | ( | bool | messageTimestampEnabled | ) | [inline, virtual] |
virtual void activemq::cmsutil::CmsTemplate::setNoLocal | ( | bool | noLocal | ) | [inline, virtual] |
virtual void activemq::cmsutil::CmsTemplate::setPriority | ( | int | priority | ) | [inline, virtual] |
Set the priority of a message when sending.
Since a default value may be defined administratively, this is only used when "isExplicitQosEnabled" equals "true".
virtual void activemq::cmsutil::CmsTemplate::setPubSubDomain | ( | bool | pubSubDomain | ) | [inline, virtual] |
Indicates whether the default destination is a topic (true) or a queue (false).
Calling this method will set the defaultDestination
property to NULL.
pubSubDomain | indicates whether to use pub-sub messaging (topics). |
Reimplemented from activemq::cmsutil::CmsDestinationAccessor.
References activemq::cmsutil::CmsDestinationAccessor::setPubSubDomain().
virtual void activemq::cmsutil::CmsTemplate::setReceiveTimeout | ( | long long | receiveTimeout | ) | [inline, virtual] |
virtual void activemq::cmsutil::CmsTemplate::setTimeToLive | ( | long long | timeToLive | ) | [inline, virtual] |
Set the time-to-live of the message when sending.
Since a default value may be defined administratively, this is only used when "isExplicitQosEnabled" equals "true".
timeToLive | the message's lifetime (in milliseconds) |
friend class ProducerExecutor [friend] |
friend class ReceiveExecutor [friend] |
friend class ResolveProducerExecutor [friend] |
friend class ResolveReceiveExecutor [friend] |
friend class SendExecutor [friend] |
const int activemq::cmsutil::CmsTemplate::DEFAULT_PRIORITY [static] |
Default message priority.
const long long activemq::cmsutil::CmsTemplate::DEFAULT_TIME_TO_LIVE [static] |
My default, messages should live forever.
const long long activemq::cmsutil::CmsTemplate::RECEIVE_TIMEOUT_INDEFINITE_WAIT [static] |
Timeout value indicating a blocking receive without timeout.
const long long activemq::cmsutil::CmsTemplate::RECEIVE_TIMEOUT_NO_WAIT [static] |
Timeout value indicating that a receive operation should check if a message is immediately available without blocking.