activemq-cpp-3.4.0
|
The client's connection to its provider. More...
#include <src/main/cms/Connection.h>
Public Member Functions | |
virtual | ~Connection () throw () |
virtual void | close ()=0 |
Closes this connection as well as any Sessions created from it (and those Sessions' consumers and producers). | |
virtual const ConnectionMetaData * | getMetaData () const =0 |
Gets the metadata for this connection. | |
virtual Session * | createSession ()=0 |
Creates an AUTO_ACKNOWLEDGE Session. | |
virtual Session * | createSession (Session::AcknowledgeMode ackMode)=0 |
Creates a new Session to work for this Connection using the specified acknowledgment mode. | |
virtual std::string | getClientID () const =0 |
Get the Client Id for this session, the client Id is provider specific and is either assigned by the connection factory or set using the setClientID method. | |
virtual void | setClientID (const std::string &clientID)=0 |
Sets the client identifier for this connection. | |
virtual ExceptionListener * | getExceptionListener () const =0 |
Gets the registered Exception Listener for this connection. | |
virtual void | setExceptionListener (ExceptionListener *listener)=0 |
Sets the registered Exception Listener for this connection. |
The client's connection to its provider.
Connections support concurrent use.
A connection serves several purposes:
Because the creation of a connection involves setting up authentication and communication, a connection is a relatively heavy-weight object. Most clients will do all their messaging with a single connection. Other more advanced applications may use several connections. The CMS API does not architect a reason for using multiple connections; however, there may be operational reasons for doing so.
A CMS client typically creates a connection, one or more sessions, and a number of message producers and consumers. When a connection is created, it is in stopped mode. That means that no messages are being delivered.
It is typical to leave the connection in stopped mode until setup is complete (that is, until all message consumers have been created). At that point, the client calls the connection's start method, and messages begin arriving at the connection's consumers. This setup convention minimizes any client confusion that may result from asynchronous message delivery while the client is still in the process of setting itself up.
A connection can be started immediately, and the setup can be done afterwards. Clients that do this must be prepared to handle asynchronous message delivery while they are still in the process of setting up.
A message producer can send messages while a connection is stopped.
virtual cms::Connection::~Connection | ( | ) | throw () [virtual] |
virtual void cms::Connection::close | ( | ) | [pure virtual] |
Closes this connection as well as any Sessions created from it (and those Sessions' consumers and producers).
CMSException |
Implements cms::Closeable.
Implemented in activemq::core::ActiveMQConnection.
virtual Session* cms::Connection::createSession | ( | Session::AcknowledgeMode | ackMode | ) | [pure virtual] |
Creates a new Session to work for this Connection using the specified acknowledgment mode.
ackMode | the Acknowledgment Mode to use. |
CMSException |
Implemented in activemq::core::ActiveMQConnection, and activemq::core::ActiveMQXAConnection.
virtual Session* cms::Connection::createSession | ( | ) | [pure virtual] |
Creates an AUTO_ACKNOWLEDGE Session.
CMSException |
Implemented in activemq::core::ActiveMQConnection.
virtual std::string cms::Connection::getClientID | ( | ) | const [pure virtual] |
Get the Client Id for this session, the client Id is provider specific and is either assigned by the connection factory or set using the setClientID method.
CMSException | if the provider fails to return the client id or an internal error occurs. |
Implemented in activemq::core::ActiveMQConnection.
virtual ExceptionListener* cms::Connection::getExceptionListener | ( | ) | const [pure virtual] |
Gets the registered Exception Listener for this connection.
Implemented in activemq::core::ActiveMQConnection.
virtual const ConnectionMetaData* cms::Connection::getMetaData | ( | ) | const [pure virtual] |
Gets the metadata for this connection.
CMSException | if the provider fails to get the connection metadata for this connection. |
Implemented in activemq::core::ActiveMQConnection.
virtual void cms::Connection::setClientID | ( | const std::string & | clientID | ) | [pure virtual] |
Sets the client identifier for this connection.
The preferred way to assign a CMS client's client identifier is for it to be configured in a client-specific ConnectionFactory object and transparently assigned to the Connection object it creates.
If a client sets the client identifier explicitly, it must do so immediately after it creates the connection and before any other action on the connection is taken. After this point, setting the client identifier is a programming error that should throw an IllegalStateException.
clientID | The unique client identifier to assign to the Connection. |
CMSException | if the provider fails to set the client id due to some internal error. |
InvalidClientIDException | if the id given is somehow invalid or is a duplicate. |
IllegalStateException | if the client tries to set the id after a Connection method has been called. |
Implemented in activemq::core::ActiveMQConnection.
virtual void cms::Connection::setExceptionListener | ( | ExceptionListener * | listener | ) | [pure virtual] |
Sets the registered Exception Listener for this connection.
listener | pointer to and ExceptionListener |
Implemented in activemq::core::ActiveMQConnection.