activemq::cmsutil::PooledSession Class Reference

A pooled session object that wraps around a delegate session. More...

#include <src/main/activemq/cmsutil/PooledSession.h>

Inheritance diagram for activemq::cmsutil::PooledSession:
Inheritance graph
[legend]

Public Member Functions

 PooledSession (SessionPool *pool, cms::Session *session)
virtual ~PooledSession ()
 Does nothing.
virtual cms::SessiongetSession ()
 Returns a non-constant reference to the internal session object.
virtual const cms::SessiongetSession () const
 Returns a constant reference to the internal session object.
virtual void close ()
 Returns this session back to the pool, but does not close or destroy the internal session object.
virtual void start ()
 Starts the service.
virtual void stop ()
 Stops this service.
virtual void commit ()
 Commits all messages done in this transaction and releases any locks currently held.
virtual void rollback ()
 Rolls back all messages done in this transaction and releases any locks currently held.
virtual void recover ()
 Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message.
virtual cms::MessageConsumercreateConsumer (const cms::Destination *destination)
 Creates a MessageConsumer for the specified destination.
virtual cms::MessageConsumercreateConsumer (const cms::Destination *destination, const std::string &selector)
 Creates a MessageConsumer for the specified destination, using a message selector.
virtual cms::MessageConsumercreateConsumer (const cms::Destination *destination, const std::string &selector, bool noLocal)
 Creates a MessageConsumer for the specified destination, using a message selector.
virtual cms::MessageConsumercreateDurableConsumer (const cms::Topic *destination, const std::string &name, const std::string &selector, bool noLocal=false)
 Creates a durable subscriber to the specified topic, using a Message selector.
virtual cms::MessageConsumercreateCachedConsumer (const cms::Destination *destination, const std::string &selector, bool noLocal)
 First checks the internal consumer cache and creates on if none exist for the given destination, selector, noLocal.
virtual cms::MessageProducercreateProducer (const cms::Destination *destination)
 Creates a MessageProducer to send messages to the specified destination.
virtual cms::MessageProducercreateCachedProducer (const cms::Destination *destination)
 First checks the internal producer cache and creates one if none exist for the given destination.
virtual cms::QueueBrowsercreateBrowser (const cms::Queue *queue)
 Creates a new QueueBrowser to peek at Messages on the given Queue.
virtual cms::QueueBrowsercreateBrowser (const cms::Queue *queue, const std::string &selector)
 Creates a new QueueBrowser to peek at Messages on the given Queue.
virtual cms::QueuecreateQueue (const std::string &queueName)
 Creates a queue identity given a Queue name.
virtual cms::TopiccreateTopic (const std::string &topicName)
 Creates a topic identity given a Queue name.
virtual cms::TemporaryQueuecreateTemporaryQueue ()
 Creates a TemporaryQueue object.
virtual cms::TemporaryTopiccreateTemporaryTopic ()
 Creates a TemporaryTopic object.
virtual cms::MessagecreateMessage ()
 Creates a new Message.
virtual cms::BytesMessagecreateBytesMessage ()
 Creates a BytesMessage.
virtual cms::BytesMessagecreateBytesMessage (const unsigned char *bytes, int bytesSize)
 Creates a BytesMessage and sets the payload to the passed value.
virtual cms::StreamMessagecreateStreamMessage ()
 Creates a new StreamMessage.
virtual cms::TextMessagecreateTextMessage ()
 Creates a new TextMessage.
virtual cms::TextMessagecreateTextMessage (const std::string &text)
 Creates a new TextMessage and set the text to the value given.
virtual cms::MapMessagecreateMapMessage ()
 Creates a new MapMessage.
virtual
cms::Session::AcknowledgeMode 
getAcknowledgeMode () const
 Returns the acknowledgment mode of the session.
virtual bool isTransacted () const
 Gets if the Sessions is a Transacted Session.
virtual void unsubscribe (const std::string &name)
 Unsubscribes a durable subscription that has been created by a client.
virtual void setMessageTransformer (cms::MessageTransformer *transformer)
 Set an MessageTransformer instance that is passed on to all MessageProducer and MessageConsumer objects created from this Session.
virtual cms::MessageTransformergetMessageTransformer () const
 Gets the currently configured MessageTransformer for this Session.

Detailed Description

A pooled session object that wraps around a delegate session.

Calls to close this session only result in giving the session back to the pool.


Constructor & Destructor Documentation

activemq::cmsutil::PooledSession::PooledSession ( SessionPool pool,
cms::Session session 
)
virtual activemq::cmsutil::PooledSession::~PooledSession (  )  [virtual]

Does nothing.


Member Function Documentation

virtual void activemq::cmsutil::PooledSession::close (  )  [virtual]

Returns this session back to the pool, but does not close or destroy the internal session object.

Exceptions:
CMSException if an error occurs while performing this operation.

Implements cms::Session.

virtual void activemq::cmsutil::PooledSession::commit (  )  [inline, virtual]

Commits all messages done in this transaction and releases any locks currently held.

Exceptions:
CMSException - If an internal error occurs.
IllegalStateException - if the method is not called by a transacted session.

Implements cms::Session.

References cms::Session::commit().

virtual cms::QueueBrowser* activemq::cmsutil::PooledSession::createBrowser ( const cms::Queue queue,
const std::string &  selector 
) [virtual]

Creates a new QueueBrowser to peek at Messages on the given Queue.

Parameters:
queue the Queue to browse
selector the Message selector to filter which messages are browsed.
Returns:
New QueueBrowser that is owned by the caller.
Exceptions:
CMSException - If an internal error occurs.
InvalidDestinationException - if the destination given is invalid.

Implements cms::Session.

virtual cms::QueueBrowser* activemq::cmsutil::PooledSession::createBrowser ( const cms::Queue queue  )  [virtual]

Creates a new QueueBrowser to peek at Messages on the given Queue.

Parameters:
queue the Queue to browse
Returns:
New QueueBrowser that is owned by the caller.
Exceptions:
CMSException - If an internal error occurs.
InvalidDestinationException - if the destination given is invalid.

Implements cms::Session.

virtual cms::BytesMessage* activemq::cmsutil::PooledSession::createBytesMessage ( const unsigned char *  bytes,
int  bytesSize 
) [inline, virtual]

Creates a BytesMessage and sets the payload to the passed value.

Parameters:
bytes an array of bytes to set in the message
bytesSize the size of the bytes array, or number of bytes to use
Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::createBytesMessage().

virtual cms::BytesMessage* activemq::cmsutil::PooledSession::createBytesMessage (  )  [inline, virtual]

Creates a BytesMessage.

Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::createBytesMessage().

virtual cms::MessageConsumer* activemq::cmsutil::PooledSession::createCachedConsumer ( const cms::Destination destination,
const std::string &  selector,
bool  noLocal 
) [virtual]

First checks the internal consumer cache and creates on if none exist for the given destination, selector, noLocal.

If created, the consumer is added to the pool's lifecycle manager.

Parameters:
destination the destination to receive on
selector the selector to use
noLocal whether or not to receive messages from the same connection
Returns:
the consumer resource
Exceptions:
cms::CMSException if something goes wrong.
virtual cms::MessageProducer* activemq::cmsutil::PooledSession::createCachedProducer ( const cms::Destination destination  )  [virtual]

First checks the internal producer cache and creates one if none exist for the given destination.

If created, the producer is added to the pool's lifecycle manager.

Parameters:
destination the destination to send on
Returns:
the producer resource
Exceptions:
cms::CMSException if something goes wrong.
virtual cms::MessageConsumer* activemq::cmsutil::PooledSession::createConsumer ( const cms::Destination destination,
const std::string &  selector,
bool  noLocal 
) [inline, virtual]

Creates a MessageConsumer for the specified destination, using a message selector.

Parameters:
destination the Destination that this consumer receiving messages for.
selector the Message Selector to use
noLocal if true, and the destination is a topic, inhibits the delivery of messages published by its own connection. The behavior for NoLocal is not specified if the destination is a queue.
Returns:
pointer to a new MessageConsumer that is owned by the caller ( caller deletes )
Exceptions:
CMSException - If an internal error occurs.
InvalidDestinationException - if an invalid destination is specified.
InvalidSelectorException - if the message selector is invalid.

Implements cms::Session.

References cms::Session::createConsumer().

virtual cms::MessageConsumer* activemq::cmsutil::PooledSession::createConsumer ( const cms::Destination destination,
const std::string &  selector 
) [inline, virtual]

Creates a MessageConsumer for the specified destination, using a message selector.

Parameters:
destination the Destination that this consumer receiving messages for.
selector the Message Selector to use
Returns:
pointer to a new MessageConsumer that is owned by the caller ( caller deletes )
Exceptions:
CMSException - If an internal error occurs.
InvalidDestinationException - if an invalid destination is specified.
InvalidSelectorException - if the message selector is invalid.

Implements cms::Session.

References cms::Session::createConsumer().

virtual cms::MessageConsumer* activemq::cmsutil::PooledSession::createConsumer ( const cms::Destination destination  )  [inline, virtual]

Creates a MessageConsumer for the specified destination.

Parameters:
destination the Destination that this consumer receiving messages for.
Returns:
pointer to a new MessageConsumer that is owned by the caller ( caller deletes )
Exceptions:
CMSException - If an internal error occurs.
InvalidDestinationException - if an invalid destination is specified.

Implements cms::Session.

References cms::Session::createConsumer().

virtual cms::MessageConsumer* activemq::cmsutil::PooledSession::createDurableConsumer ( const cms::Topic destination,
const std::string &  name,
const std::string &  selector,
bool  noLocal = false 
) [inline, virtual]

Creates a durable subscriber to the specified topic, using a Message selector.

Sessions that create durable consumers must use the same client Id as was used the last time the subscription was created in order to receive all messages that were delivered while the client was offline.

Parameters:
destination the topic to subscribe to
name The name used to identify the subscription
selector the Message Selector to use
noLocal if true, and the destination is a topic, inhibits the delivery of messages published by its own connection. The behavior for NoLocal is not specified if the destination is a queue.
Returns:
pointer to a new durable MessageConsumer that is owned by the caller ( caller deletes )
Exceptions:
CMSException - If an internal error occurs.
InvalidDestinationException - if an invalid destination is specified.
InvalidSelectorException - if the message selector is invalid.

Implements cms::Session.

References cms::Session::createDurableConsumer().

virtual cms::MapMessage* activemq::cmsutil::PooledSession::createMapMessage (  )  [inline, virtual]

Creates a new MapMessage.

Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::createMapMessage().

virtual cms::Message* activemq::cmsutil::PooledSession::createMessage (  )  [inline, virtual]

Creates a new Message.

Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::createMessage().

virtual cms::MessageProducer* activemq::cmsutil::PooledSession::createProducer ( const cms::Destination destination  )  [inline, virtual]

Creates a MessageProducer to send messages to the specified destination.

Parameters:
destination the Destination to send on
Returns:
New MessageProducer that is owned by the caller.
Exceptions:
CMSException - If an internal error occurs.
InvalidDestinationException - if an invalid destination is specified.

Implements cms::Session.

References cms::Session::createProducer().

virtual cms::Queue* activemq::cmsutil::PooledSession::createQueue ( const std::string &  queueName  )  [inline, virtual]

Creates a queue identity given a Queue name.

Parameters:
queueName the name of the new Queue
Returns:
new Queue pointer that is owned by the caller.
Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::createQueue().

virtual cms::StreamMessage* activemq::cmsutil::PooledSession::createStreamMessage (  )  [inline, virtual]

Creates a new StreamMessage.

Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::createStreamMessage().

virtual cms::TemporaryQueue* activemq::cmsutil::PooledSession::createTemporaryQueue (  )  [inline, virtual]

Creates a TemporaryQueue object.

Returns:
new TemporaryQueue pointer that is owned by the caller.
Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::createTemporaryQueue().

virtual cms::TemporaryTopic* activemq::cmsutil::PooledSession::createTemporaryTopic (  )  [inline, virtual]

Creates a TemporaryTopic object.

Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::createTemporaryTopic().

virtual cms::TextMessage* activemq::cmsutil::PooledSession::createTextMessage ( const std::string &  text  )  [inline, virtual]

Creates a new TextMessage and set the text to the value given.

Parameters:
text the initial text for the message
Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::createTextMessage().

virtual cms::TextMessage* activemq::cmsutil::PooledSession::createTextMessage (  )  [inline, virtual]

Creates a new TextMessage.

Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::createTextMessage().

virtual cms::Topic* activemq::cmsutil::PooledSession::createTopic ( const std::string &  topicName  )  [inline, virtual]

Creates a topic identity given a Queue name.

Parameters:
topicName the name of the new Topic
Returns:
new Topic pointer that is owned by the caller.
Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::createTopic().

virtual cms::Session::AcknowledgeMode activemq::cmsutil::PooledSession::getAcknowledgeMode (  )  const [inline, virtual]

Returns the acknowledgment mode of the session.

Returns:
the Sessions Acknowledge Mode
Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::getAcknowledgeMode().

virtual cms::MessageTransformer* activemq::cmsutil::PooledSession::getMessageTransformer (  )  const [inline, virtual]

Gets the currently configured MessageTransformer for this Session.

Returns:
the pointer to the currently set cms::MessageTransformer.

Implements cms::Session.

References cms::Session::getMessageTransformer().

virtual const cms::Session* activemq::cmsutil::PooledSession::getSession (  )  const [inline, virtual]

Returns a constant reference to the internal session object.

Returns:
the session object.
virtual cms::Session* activemq::cmsutil::PooledSession::getSession (  )  [inline, virtual]

Returns a non-constant reference to the internal session object.

Returns:
the session object.
virtual bool activemq::cmsutil::PooledSession::isTransacted (  )  const [inline, virtual]

Gets if the Sessions is a Transacted Session.

Returns:
transacted true - false.
Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::isTransacted().

virtual void activemq::cmsutil::PooledSession::recover (  )  [inline, virtual]

Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message.

All consumers deliver messages in a serial order. Acknowledging a received message automatically acknowledges all messages that have been delivered to the client.

Restarting a session causes it to take the following actions:

  • Stop message delivery
  • Mark all messages that might have been delivered but not acknowledged as "redelivered"
  • Restart the delivery sequence including all unacknowledged messages that had been previously delivered. Redelivered messages do not have to be delivered in exactly their original delivery order.
Exceptions:
CMSException - if the CMS provider fails to stop and restart message delivery due to some internal error.
IllegalStateException - if the method is called by a transacted session.

Implements cms::Session.

References cms::Session::recover().

virtual void activemq::cmsutil::PooledSession::rollback (  )  [inline, virtual]

Rolls back all messages done in this transaction and releases any locks currently held.

Exceptions:
CMSException - If an internal error occurs.
IllegalStateException - if the method is not called by a transacted session.

Implements cms::Session.

References cms::Session::rollback().

virtual void activemq::cmsutil::PooledSession::setMessageTransformer ( cms::MessageTransformer transformer  )  [inline, virtual]

Set an MessageTransformer instance that is passed on to all MessageProducer and MessageConsumer objects created from this Session.

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:
transformer Pointer to the cms::MessageTransformer to set on all MessageConsumers and MessageProducers.

Implements cms::Session.

References cms::Session::setMessageTransformer().

virtual void activemq::cmsutil::PooledSession::start (  )  [inline, virtual]

Starts the service.

Exceptions:
CMSException if an internal error occurs while starting.

Implements cms::Startable.

References cms::Startable::start().

virtual void activemq::cmsutil::PooledSession::stop (  )  [inline, virtual]

Stops this service.

Exceptions:
CMSException - if an internal error occurs while stopping the Service.

Implements cms::Stoppable.

References cms::Stoppable::stop().

virtual void activemq::cmsutil::PooledSession::unsubscribe ( const std::string &  name  )  [inline, virtual]

Unsubscribes a durable subscription that has been created by a client.

This method deletes the state being maintained on behalf of the subscriber by its provider. It is erroneous for a client to delete a durable subscription while there is an active MessageConsumer or Subscriber for the subscription, or while a consumed message is part of a pending transaction or has not been acknowledged in the session.

Parameters:
name The name used to identify this subscription
Exceptions:
CMSException - If an internal error occurs.

Implements cms::Session.

References cms::Session::unsubscribe().


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

Generated on 1 Dec 2014 for activemq-cpp-3.8.2 by  doxygen 1.6.1