activemq-cpp-3.6.0
activemq::core::ActiveMQSession Class Reference

#include <src/main/activemq/core/ActiveMQSession.h>

Inheritance diagram for activemq::core::ActiveMQSession:

Public Member Functions

 ActiveMQSession (Pointer< activemq::core::kernels::ActiveMQSessionKernel > kernel)
virtual ~ActiveMQSession ()
virtual void start ()
 Stops asynchronous message delivery.
virtual void stop ()
 Starts asynchronous message delivery.
bool isStarted () const
 Indicates whether or not the session is currently in the started state.
virtual void close ()
 Closes this session as well as any active child consumers or producers.
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::MessageProducercreateProducer (const cms::Destination *destination)
 Creates a MessageProducer to send messages to the specified 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.
cms::ExceptionListenergetExceptionListener ()
 This method gets any registered exception listener of this sessions connection and returns it.
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.
const commands::SessionInfogetSessionInfo () const
 Gets the Session Information object for this session, if the session is closed than this method throws an exception.
const commands::SessionIdgetSessionId () const
 Gets the Session Id object for this session, if the session is closed than this method throws an exception.
ActiveMQConnectiongetConnection () const
 Gets the ActiveMQConnection that is associated with this session.
- Public Member Functions inherited from cms::Session
virtual ~Session ()
- Public Member Functions inherited from cms::Closeable
virtual ~Closeable ()
- Public Member Functions inherited from cms::Startable
virtual ~Startable ()
- Public Member Functions inherited from cms::Stoppable
virtual ~Stoppable ()

Protected Attributes

Pointer
< activemq::core::kernels::ActiveMQSessionKernel
kernel

Additional Inherited Members

- Public Types inherited from cms::Session
enum  AcknowledgeMode {
  AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, SESSION_TRANSACTED,
  INDIVIDUAL_ACKNOWLEDGE
}

Constructor & Destructor Documentation

activemq::core::ActiveMQSession::ActiveMQSession ( Pointer< activemq::core::kernels::ActiveMQSessionKernel kernel)
virtual activemq::core::ActiveMQSession::~ActiveMQSession ( )
virtual

Member Function Documentation

virtual void activemq::core::ActiveMQSession::close ( )
virtual

Closes this session as well as any active child consumers or producers.

Exceptions
CMSException- If an internal error occurs.

Implements cms::Session.

virtual void activemq::core::ActiveMQSession::commit ( )
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.

Reimplemented in activemq::core::ActiveMQXASession.

virtual cms::QueueBrowser* activemq::core::ActiveMQSession::createBrowser ( const cms::Queue queue)
virtual

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

Parameters
queuethe 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::QueueBrowser* activemq::core::ActiveMQSession::createBrowser ( const cms::Queue queue,
const std::string &  selector 
)
virtual

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

Parameters
queuethe Queue to browse
selectorthe 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::BytesMessage* activemq::core::ActiveMQSession::createBytesMessage ( )
virtual

Creates a BytesMessage.

Exceptions
CMSException- If an internal error occurs.

Implements cms::Session.

virtual cms::BytesMessage* activemq::core::ActiveMQSession::createBytesMessage ( const unsigned char *  bytes,
int  bytesSize 
)
virtual

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

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

Implements cms::Session.

virtual cms::MessageConsumer* activemq::core::ActiveMQSession::createConsumer ( const cms::Destination destination)
virtual

Creates a MessageConsumer for the specified destination.

Parameters
destinationthe 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.

virtual cms::MessageConsumer* activemq::core::ActiveMQSession::createConsumer ( const cms::Destination destination,
const std::string &  selector 
)
virtual

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

Parameters
destinationthe Destination that this consumer receiving messages for.
selectorthe 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.

virtual cms::MessageConsumer* activemq::core::ActiveMQSession::createConsumer ( const cms::Destination destination,
const std::string &  selector,
bool  noLocal 
)
virtual

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

Parameters
destinationthe Destination that this consumer receiving messages for.
selectorthe Message Selector to use
noLocalif 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.

virtual cms::MessageConsumer* activemq::core::ActiveMQSession::createDurableConsumer ( const cms::Topic destination,
const std::string &  name,
const std::string &  selector,
bool  noLocal = false 
)
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
destinationthe topic to subscribe to
nameThe name used to identify the subscription
selectorthe Message Selector to use
noLocalif 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.

virtual cms::MapMessage* activemq::core::ActiveMQSession::createMapMessage ( )
virtual

Creates a new MapMessage.

Exceptions
CMSException- If an internal error occurs.

Implements cms::Session.

virtual cms::Message* activemq::core::ActiveMQSession::createMessage ( )
virtual

Creates a new Message.

Exceptions
CMSException- If an internal error occurs.

Implements cms::Session.

virtual cms::MessageProducer* activemq::core::ActiveMQSession::createProducer ( const cms::Destination destination)
virtual

Creates a MessageProducer to send messages to the specified destination.

Parameters
destinationthe 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.

virtual cms::Queue* activemq::core::ActiveMQSession::createQueue ( const std::string &  queueName)
virtual

Creates a queue identity given a Queue name.

Parameters
queueNamethe 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.

virtual cms::StreamMessage* activemq::core::ActiveMQSession::createStreamMessage ( )
virtual

Creates a new StreamMessage.

Exceptions
CMSException- If an internal error occurs.

Implements cms::Session.

virtual cms::TemporaryQueue* activemq::core::ActiveMQSession::createTemporaryQueue ( )
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.

virtual cms::TemporaryTopic* activemq::core::ActiveMQSession::createTemporaryTopic ( )
virtual

Creates a TemporaryTopic object.

Exceptions
CMSException- If an internal error occurs.

Implements cms::Session.

virtual cms::TextMessage* activemq::core::ActiveMQSession::createTextMessage ( )
virtual

Creates a new TextMessage.

Exceptions
CMSException- If an internal error occurs.

Implements cms::Session.

virtual cms::TextMessage* activemq::core::ActiveMQSession::createTextMessage ( const std::string &  text)
virtual

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

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

Implements cms::Session.

virtual cms::Topic* activemq::core::ActiveMQSession::createTopic ( const std::string &  topicName)
virtual

Creates a topic identity given a Queue name.

Parameters
topicNamethe 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.

virtual cms::Session::AcknowledgeMode activemq::core::ActiveMQSession::getAcknowledgeMode ( ) const
inlinevirtual

Returns the acknowledgment mode of the session.

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

Implements cms::Session.

ActiveMQConnection* activemq::core::ActiveMQSession::getConnection ( ) const
inline

Gets the ActiveMQConnection that is associated with this session.

cms::ExceptionListener* activemq::core::ActiveMQSession::getExceptionListener ( )
inline

This method gets any registered exception listener of this sessions connection and returns it.

Mainly intended for use by the objects that this session creates so that they can notify the client of exceptions that occur in the context of another thread.

Returns
cms::ExceptionListener pointer or NULL
virtual cms::MessageTransformer* activemq::core::ActiveMQSession::getMessageTransformer ( ) const
inlinevirtual

Gets the currently configured MessageTransformer for this Session.

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

Implements cms::Session.

const commands::SessionId& activemq::core::ActiveMQSession::getSessionId ( ) const
inline

Gets the Session Id object for this session, if the session is closed than this method throws an exception.

Returns
SessionId Reference
const commands::SessionInfo& activemq::core::ActiveMQSession::getSessionInfo ( ) const
inline

Gets the Session Information object for this session, if the session is closed than this method throws an exception.

Returns
SessionInfo Reference
bool activemq::core::ActiveMQSession::isStarted ( ) const
inline

Indicates whether or not the session is currently in the started state.

virtual bool activemq::core::ActiveMQSession::isTransacted ( ) const
inlinevirtual

Gets if the Sessions is a Transacted Session.

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

Implements cms::Session.

Reimplemented in activemq::core::ActiveMQXASession.

virtual void activemq::core::ActiveMQSession::recover ( )
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.

virtual void activemq::core::ActiveMQSession::rollback ( )
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.

Reimplemented in activemq::core::ActiveMQXASession.

virtual void activemq::core::ActiveMQSession::setMessageTransformer ( cms::MessageTransformer transformer)
inlinevirtual

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

Parameters
transformerPointer to the cms::MessageTransformer to set on all MessageConsumers and MessageProducers.

Implements cms::Session.

virtual void activemq::core::ActiveMQSession::start ( )
virtual

Stops asynchronous message delivery.

Implements cms::Startable.

virtual void activemq::core::ActiveMQSession::stop ( )
virtual

Starts asynchronous message delivery.

Implements cms::Stoppable.

virtual void activemq::core::ActiveMQSession::unsubscribe ( const std::string &  name)
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
nameThe name used to identify this subscription
Exceptions
CMSException- If an internal error occurs.

Implements cms::Session.

Field Documentation

Pointer<activemq::core::kernels::ActiveMQSessionKernel> activemq::core::ActiveMQSession::kernel
protected

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