18#ifndef _ACTIVEMQ_CMSUTIL_CMSTEMPLATE_H_
19#define _ACTIVEMQ_CMSUTIL_CMSTEMPLATE_H_
60 class AMQCPP_API CmsTemplate :
public CmsDestinationAccessor {
100 ProducerExecutor(
const ProducerExecutor&);
101 ProducerExecutor& operator=(
const ProducerExecutor&);
123 class ResolveProducerExecutor;
125 class ResolveProducerExecutor :
public ProducerExecutor {
128 std::string destinationName;
132 ResolveProducerExecutor(
const ResolveProducerExecutor&);
133 ResolveProducerExecutor& operator=(
const ResolveProducerExecutor&);
139 const std::string& destinationName)
140 : ProducerExecutor(
action,
parent,
NULL), destinationName(destinationName) {
161 SendExecutor(
const SendExecutor&);
162 SendExecutor& operator=(
const SendExecutor&);
174 parent->doSend(session, producer, messageCreator);
181 class ReceiveExecutor;
194 ReceiveExecutor(
const ReceiveExecutor&);
195 ReceiveExecutor& operator=(
const ReceiveExecutor&);
220 class ResolveReceiveExecutor;
222 class ResolveReceiveExecutor :
public ReceiveExecutor {
225 std::string destinationName;
229 ResolveReceiveExecutor(
const ResolveReceiveExecutor&);
230 ResolveReceiveExecutor& operator=(
const ResolveReceiveExecutor&);
235 bool noLocal,
const std::string& destinationName) :
254 std::string defaultDestinationName;
256 bool messageIdEnabled;
258 bool messageTimestampEnabled;
262 long long receiveTimeout;
264 bool explicitQosEnabled;
270 long long timeToLive;
276 CmsTemplate(
const CmsTemplate&);
277 CmsTemplate& operator=(
const CmsTemplate&);
296 this->defaultDestination = defaultDestination;
304 return this->defaultDestination;
312 return this->defaultDestination;
325 if (defaultDestinationName != this->defaultDestinationName) {
326 this->defaultDestination =
NULL;
327 this->defaultDestinationName = defaultDestinationName;
339 return this->defaultDestinationName;
351 this->defaultDestination =
NULL;
357 this->messageIdEnabled = messageIdEnabled;
361 return this->messageIdEnabled;
365 this->messageTimestampEnabled = messageTimestampEnabled;
369 return this->messageTimestampEnabled;
373 this->noLocal = noLocal;
377 return this->noLocal;
381 this->receiveTimeout = receiveTimeout;
385 return this->receiveTimeout;
397 this->explicitQosEnabled = explicitQosEnabled;
413 return this->explicitQosEnabled;
425 this->deliveryMode = (deliveryPersistent ? 0 : 1);
437 this->deliveryMode = deliveryMode;
444 return this->deliveryMode;
455 this->priority = priority;
462 return this->priority;
474 this->timeToLive = timeToLive;
481 return this->timeToLive;
639 void createSessionPools();
644 void destroySessionPools();
652 void checkDefaultDestination();
711 const std::string& selector,
bool noLocal);
#define AMQCPP_API
Definition Config.h:30
virtual bool isPubSubDomain() const
Definition CmsDestinationAccessor.h:64
virtual void setPubSubDomain(bool pubSubDomain)
Definition CmsDestinationAccessor.h:68
Definition CmsTemplate.h:91
ProducerExecutor(ProducerCallback *action, CmsTemplate *parent, cms::Destination *destination)
Definition CmsTemplate.h:105
virtual ~ProducerExecutor()
Definition CmsTemplate.h:111
virtual cms::Destination * getDestination(cms::Session *session AMQCPP_UNUSED)
Definition CmsTemplate.h:115
cms::Destination * destination
Definition CmsTemplate.h:96
ProducerCallback * action
Definition CmsTemplate.h:94
virtual void doInCms(cms::Session *session)
Execute any number of operations against the supplied CMS session.
CmsTemplate * parent
Definition CmsTemplate.h:95
Definition CmsTemplate.h:183
cms::Destination * destination
Definition CmsTemplate.h:186
ReceiveExecutor(CmsTemplate *parent, cms::Destination *destination, const std::string &selector, bool noLocal)
Definition CmsTemplate.h:199
virtual void doInCms(cms::Session *session)
Execute any number of operations against the supplied CMS session.
virtual ~ReceiveExecutor()
Definition CmsTemplate.h:204
virtual cms::Destination * getDestination(cms::Session *session AMQCPP_UNUSED)
Definition CmsTemplate.h:208
cms::Message * getMessage()
Definition CmsTemplate.h:212
CmsTemplate * parent
Definition CmsTemplate.h:190
bool noLocal
Definition CmsTemplate.h:188
std::string selector
Definition CmsTemplate.h:187
cms::Message * message
Definition CmsTemplate.h:189
Definition CmsTemplate.h:125
virtual cms::Destination * getDestination(cms::Session *session)
ResolveProducerExecutor(ProducerCallback *action, CmsTemplate *parent, const std::string &destinationName)
Definition CmsTemplate.h:137
virtual ~ResolveProducerExecutor()
Definition CmsTemplate.h:143
Definition CmsTemplate.h:222
virtual cms::Destination * getDestination(cms::Session *session)
ResolveReceiveExecutor(CmsTemplate *parent, const std::string &selector, bool noLocal, const std::string &destinationName)
Definition CmsTemplate.h:234
virtual ~ResolveReceiveExecutor()
Definition CmsTemplate.h:239
Definition CmsTemplate.h:153
virtual ~SendExecutor()
Definition CmsTemplate.h:170
SendExecutor(MessageCreator *messageCreator, CmsTemplate *parent)
Definition CmsTemplate.h:166
virtual void doInCms(cms::Session *session, cms::MessageProducer *producer)
Execute an action given a session and producer.
Definition CmsTemplate.h:173
virtual void setExplicitQosEnabled(bool explicitQosEnabled)
Set if the QOS values (deliveryMode, priority, timeToLive) should be used for sending a message.
Definition CmsTemplate.h:396
static const long long DEFAULT_TIME_TO_LIVE
My default, messages should live forever.
Definition CmsTemplate.h:82
static const long long RECEIVE_TIMEOUT_NO_WAIT
Timeout value indicating that a receive operation should check if a message is immediately available ...
Definition CmsTemplate.h:67
virtual void execute(ProducerCallback *action)
Executes the given action and provides it with a CMS Session and producer.
virtual void setDeliveryMode(int deliveryMode)
Set the delivery mode to use when sending a message.
Definition CmsTemplate.h:436
virtual void execute(cms::Destination *dest, 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 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...
virtual long long getTimeToLive() const
Return the time-to-live of the message when sending.
Definition CmsTemplate.h:480
virtual void setReceiveTimeout(long long receiveTimeout)
Definition CmsTemplate.h:380
CmsTemplate(cms::ConnectionFactory *connectionFactory)
virtual void setDefaultDestination(cms::Destination *defaultDestination)
Sets the destination object to be used by default for send/receive operations.
Definition CmsTemplate.h:295
virtual void send(cms::Destination *dest, MessageCreator *messageCreator)
Convenience method for sending a message to the specified destination.
virtual void execute(const std::string &destinationName, ProducerCallback *action)
Executes the given action and provides it with a CMS Session and producer.
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...
static const int DEFAULT_PRIORITY
Default message priority.
Definition CmsTemplate.h:77
virtual bool isNoLocal() const
Definition CmsTemplate.h:376
virtual cms::Message * receive()
Performs a synchronous read from the default destination.
virtual void setDefaultDestinationName(const std::string &defaultDestinationName)
Sets the name of the default destination to be used from send/receive operations.
Definition CmsTemplate.h:324
virtual const cms::Destination * getDefaultDestination() const
Retrieves the default destination to be used for send/receive operations.
Definition CmsTemplate.h:303
virtual cms::Destination * getDefaultDestination()
Retrieves the default destination to be used for send/receive operations.
Definition CmsTemplate.h:311
virtual void setTimeToLive(long long timeToLive)
Set the time-to-live of the message when sending.
Definition CmsTemplate.h:473
static const long long RECEIVE_TIMEOUT_INDEFINITE_WAIT
Timeout value indicating a blocking receive without timeout.
Definition CmsTemplate.h:72
virtual bool isExplicitQosEnabled() const
If "true", then the values of deliveryMode, priority, and timeToLive will be used when sending a mess...
Definition CmsTemplate.h:412
virtual int getDeliveryMode() const
Return the delivery mode to use when sending a message.
Definition CmsTemplate.h:443
void destroy()
Shuts down this object and destroys any allocated resources.
virtual long long getReceiveTimeout() const
Definition CmsTemplate.h:384
virtual const std::string getDefaultDestinationName() const
Gets the name of the default destination to be used for send/receive operations.
Definition CmsTemplate.h:338
virtual void execute(SessionCallback *action)
Executes the given action within a CMS Session.
virtual bool isMessageTimestampEnabled() const
Definition CmsTemplate.h:368
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.
void init()
Initializes this object and prepares it for use.
virtual int getPriority() const
Return the priority of a message when sending.
Definition CmsTemplate.h:461
virtual bool isMessageIdEnabled() const
Definition CmsTemplate.h:360
virtual void setPriority(int priority)
Set the priority of a message when sending.
Definition CmsTemplate.h:454
virtual void setPubSubDomain(bool pubSubDomain)
Indicates whether the default destination is a topic (true) or a queue (false).
Definition CmsTemplate.h:349
virtual void setNoLocal(bool noLocal)
Definition CmsTemplate.h:372
virtual cms::Message * receiveSelected(const std::string &selector)
Performs a synchronous read consuming only messages identified by the given selector.
virtual void setMessageTimestampEnabled(bool messageTimestampEnabled)
Definition CmsTemplate.h:364
virtual void send(const std::string &destinationName, MessageCreator *messageCreator)
Convenience method for sending a message to the specified destination.
virtual void setMessageIdEnabled(bool messageIdEnabled)
Definition CmsTemplate.h:356
virtual void setDeliveryPersistent(bool deliveryPersistent)
Set whether message delivery should be persistent or non-persistent, specified as boolean value ("tru...
Definition CmsTemplate.h:424
Creates the user-defined message to be sent by the CmsTemplate.
Definition MessageCreator.h:34
A pooled session object that wraps around a delegate session.
Definition PooledSession.h:37
Callback for sending a message to a CMS destination.
Definition ProducerCallback.h:33
Callback for executing any number of operations on a provided CMS Session.
Definition SessionCallback.h:33
A pool of CMS sessions from the same connection and with the same acknowledge mode.
Definition SessionPool.h:39
Defines the interface for a factory that creates connection objects, the Connection objects returned ...
Definition ConnectionFactory.h:41
The client's connection to its provider.
Definition Connection.h:70
A Destination object encapsulates a provider-specific address.
Definition Destination.h:39
A client uses a MessageConsumer to received messages from a destination.
Definition MessageConsumer.h:63
Root of all messages.
Definition Message.h:88
A client uses a MessageProducer object to send messages to a Destination.
Definition MessageProducer.h:60
A Session object is a single-threaded context for producing and consuming messages.
Definition Session.h:105
@ SESSION_TRANSACTED
Messages will be consumed when the transaction commits.
Definition Session.h:139
#define NULL
Definition Config.h:33
Definition CachedConsumer.h:25
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition CachedConsumer.h:24