Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

javax::jms::Connection Class Reference

A Connection object is a client's active connection to its JMS provider. More...

#include <javax_jms_Connection.h>

Inheritance diagram for javax::jms::Connection:

Inheritance graph
[legend]
Collaboration diagram for javax::jms::Connection:

Collaboration graph
[legend]
List of all members.

Public Types

enum  {
  xmogDefaultFlags = xmog_base::GLOBAL, xmogMajorVersion = 3, xmogMinorVersion = 2, xmogPatchVersion = 9,
  xmogBuildNumber = 2047
}
typedef ::xmog_java_array_template<
::javax::jms::Connection
array1D
typedef ::xmog_java_array_template<
::xmog_java_array_template<
::javax::jms::Connection > > 
array2D

Public Member Functions

virtual void close (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags)
 Closes the connection.
virtual ::javax::jms::ConnectionConsumer createConnectionConsumer (const ::javax::jms::Destination &destination, const ::java::lang::String &messageSelector, const ::javax::jms::ServerSessionPool &sessionPool, jint maxMessages,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags)
 Creates a connection consumer for this connection (optional operation).
virtual ::javax::jms::ConnectionConsumer createDurableConnectionConsumer (const ::javax::jms::Topic &topic, const ::java::lang::String &subscriptionName, const ::java::lang::String &messageSelector, const ::javax::jms::ServerSessionPool &sessionPool, jint maxMessages,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags)
 Create a durable connection consumer for this connection (optional operation).
virtual ::javax::jms::Session createSession (bool transacted, jint acknowledgeMode,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags)
 Creates a Session object.
virtual ::java::lang::String getClientID (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags)
 Gets the client identifier for this connection.
virtual ::javax::jms::ExceptionListener getExceptionListener (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags)
 Gets the ExceptionListener object for this connection.
virtual ::javax::jms::ConnectionMetaData getMetaData (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags)
 Gets the metadata for this connection.
virtual void setClientID (const ::java::lang::String &clientID,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags)
 Sets the client identifier for this connection.
virtual void setExceptionListener (const ::javax::jms::ExceptionListener &listener,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags)
 Sets an exception listener for this connection.
virtual void start (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags)
 Starts (or restarts) a connection's delivery of incoming messages.
virtual void stop (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags)
 Temporarily stops a connection's delivery of incoming messages.

Detailed Description

A Connection object is a client's active connection to its JMS provider.

It typically allocates provider resources outside the Java virtual machine (JVM).

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 heavyweight object. Most clients will do all their messaging with a single connection. Other more advanced applications may use several connections. The JMS API does not architect a reason for using multiple connections; however, there may be operational reasons for doing so.

A JMS 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.

Author:
Mark Hapner

Rich Burridge

Kate Stout


Member Function Documentation

virtual void javax::jms::Connection::close ::xmog_localenv p_xenv = NULL,
xmog_flags  f_xflags = xmogDefaultFlags
[virtual]
 

Closes the connection.

Since a provider typically allocates significant resources outside the JVM on behalf of a connection, clients should close these resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.

There is no need to close the sessions, producers, and consumers of a closed connection.

Closing a connection causes all temporary destinations to be deleted.

When this method is invoked, it should not return until message processing has been shut down in an orderly fashion. This means that all message listeners that may have been running have returned, and that all pending receives have returned. A close terminates all pending message receives on the connection's sessions' consumers. The receives may return with a message or with null, depending on whether there was a message available at the time of the close. If one or more of the connection's sessions' message listeners is processing a message at the time when connection close is invoked, all the facilities of the connection and its sessions must remain available to those listeners until they return control to the JMS provider.

Closing a connection causes any of its sessions' transactions in progress to be rolled back. In the case where a session's work is coordinated by an external transaction manager, a session's commit and rollback methods are not used and the result of a closed session's work is determined later by the transaction manager.

Closing a connection does NOT force an acknowledgment of client-acknowledged sessions.

Invoking the acknowledge method of a received message from a closed connection's session must throw an IllegalStateException. Closing a closed connection must NOT throw an exception.

Parameters:
p_xenv the local call environment. The default value is NULL.
f_xflags the flags that allow control over the reference type and other internal matters. The default value is xmog_base::GLOBAL.
Returns:

virtual ::javax::jms::ConnectionConsumer javax::jms::Connection::createConnectionConsumer const ::javax::jms::Destination destination,
const ::java::lang::String messageSelector,
const ::javax::jms::ServerSessionPool sessionPool,
jint  maxMessages,
::xmog_localenv p_xenv = NULL,
xmog_flags  f_xflags = xmogDefaultFlags
 

Creates a connection consumer for this connection (optional operation).

This is an expert facility not used by regular JMS clients.

Parameters:
destination the destination to access
messageSelector only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
sessionPool the server session pool to associate with this connection consumer
maxMessages the maximum number of messages that can be assigned to a server session at one time
p_xenv the local call environment. The default value is NULL.
f_xflags the flags that allow control over the reference type and other internal matters. The default value is xmog_base::GLOBAL.
Returns:
the connection consumer

virtual ::javax::jms::ConnectionConsumer javax::jms::Connection::createDurableConnectionConsumer const ::javax::jms::Topic topic,
const ::java::lang::String subscriptionName,
const ::java::lang::String messageSelector,
const ::javax::jms::ServerSessionPool sessionPool,
jint  maxMessages,
::xmog_localenv p_xenv = NULL,
xmog_flags  f_xflags = xmogDefaultFlags
 

Create a durable connection consumer for this connection (optional operation).

This is an expert facility not used by regular JMS clients.

Parameters:
topic topic to access
subscriptionName durable subscription name
messageSelector only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
sessionPool the server session pool to associate with this durable connection consumer
maxMessages the maximum number of messages that can be assigned to a server session at one time
p_xenv the local call environment. The default value is NULL.
f_xflags the flags that allow control over the reference type and other internal matters. The default value is xmog_base::GLOBAL.
Returns:
the durable connection consumer

Reimplemented in javax::jms::TopicConnection, and javax::jms::XATopicConnection.

virtual ::javax::jms::Session javax::jms::Connection::createSession bool  transacted,
jint  acknowledgeMode,
::xmog_localenv p_xenv = NULL,
xmog_flags  f_xflags = xmogDefaultFlags
 

Creates a Session object.

Parameters:
transacted indicates whether the session is transacted
acknowledgeMode indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values are Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, and Session.DUPS_OK_ACKNOWLEDGE.
p_xenv the local call environment. The default value is NULL.
f_xflags the flags that allow control over the reference type and other internal matters. The default value is xmog_base::GLOBAL.
Returns:
a newly created session

Reimplemented in javax::jms::XAConnection, javax::jms::XAQueueConnection, and javax::jms::XATopicConnection.

virtual ::java::lang::String javax::jms::Connection::getClientID ::xmog_localenv p_xenv = NULL,
xmog_flags  f_xflags = xmogDefaultFlags
 

Gets the client identifier for this connection.

This value is specific to the JMS provider. It is either preconfigured by an administrator in a ConnectionFactory object or assigned dynamically by the application by calling the setClientID method.

Parameters:
p_xenv the local call environment. The default value is NULL.
f_xflags the flags that allow control over the reference type and other internal matters. The default value is xmog_base::GLOBAL.
Returns:
the unique client identifier

virtual ::javax::jms::ExceptionListener javax::jms::Connection::getExceptionListener ::xmog_localenv p_xenv = NULL,
xmog_flags  f_xflags = xmogDefaultFlags
 

Gets the ExceptionListener object for this connection.

Not every Connection has an ExceptionListener associated with it.

Parameters:
p_xenv the local call environment. The default value is NULL.
f_xflags the flags that allow control over the reference type and other internal matters. The default value is xmog_base::GLOBAL.
Returns:
the ExceptionListener for this connection, or null. if no ExceptionListener is associated with this connection.

virtual ::javax::jms::ConnectionMetaData javax::jms::Connection::getMetaData ::xmog_localenv p_xenv = NULL,
xmog_flags  f_xflags = xmogDefaultFlags
 

Gets the metadata for this connection.

Parameters:
p_xenv the local call environment. The default value is NULL.
f_xflags the flags that allow control over the reference type and other internal matters. The default value is xmog_base::GLOBAL.
Returns:
the connection metadata

virtual void javax::jms::Connection::setClientID const ::java::lang::String clientID,
::xmog_localenv p_xenv = NULL,
xmog_flags  f_xflags = xmogDefaultFlags
[virtual]
 

Sets the client identifier for this connection.

The preferred way to assign a JMS 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.

Alternatively, a client can set a connection's client identifier using a provider-specific value. The facility to set a connection's client identifier explicitly is not a mechanism for overriding the identifier that has been administratively configured. It is provided for the case where no administratively specified identifier exists. If one does exist, an attempt to change it by setting it must throw an IllegalStateException. 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.

The purpose of the client identifier is to associate a connection and its objects with a state maintained on behalf of the client by a provider. The only such state identified by the JMS API is that required to support durable subscriptions.

If another connection with the same clientID is already running when this method is called, the JMS provider should detect the duplicate ID and throw an InvalidClientIDException.

Parameters:
clientID the unique client identifier
p_xenv the local call environment. The default value is NULL.
f_xflags the flags that allow control over the reference type and other internal matters. The default value is xmog_base::GLOBAL.
Returns:

virtual void javax::jms::Connection::setExceptionListener const ::javax::jms::ExceptionListener listener,
::xmog_localenv p_xenv = NULL,
xmog_flags  f_xflags = xmogDefaultFlags
[virtual]
 

Sets an exception listener for this connection.

If a JMS provider detects a serious problem with a connection, it informs the connection's ExceptionListener, if one has been registered. It does this by calling the listener's onException method, passing it a JMSException object describing the problem.

An exception listener allows a client to be notified of a problem asynchronously. Some connections only consume messages, so they would have no other way to learn their connection has failed.

A connection serializes execution of its ExceptionListener.

A JMS provider should attempt to resolve connection problems itself before it notifies the client of them.

Parameters:
listener the exception listener
p_xenv the local call environment. The default value is NULL.
f_xflags the flags that allow control over the reference type and other internal matters. The default value is xmog_base::GLOBAL.
Returns:

virtual void javax::jms::Connection::start ::xmog_localenv p_xenv = NULL,
xmog_flags  f_xflags = xmogDefaultFlags
[virtual]
 

Starts (or restarts) a connection's delivery of incoming messages.

A call to start on a connection that has already been started is ignored.

Parameters:
p_xenv the local call environment. The default value is NULL.
f_xflags the flags that allow control over the reference type and other internal matters. The default value is xmog_base::GLOBAL.
Returns:

virtual void javax::jms::Connection::stop ::xmog_localenv p_xenv = NULL,
xmog_flags  f_xflags = xmogDefaultFlags
[virtual]
 

Temporarily stops a connection's delivery of incoming messages.

Delivery can be restarted using the connection's start method. When the connection is stopped, delivery to all the connection's message consumers is inhibited: synchronous receives block, and messages are not delivered to message listeners.

This call blocks until receives and/or message listeners in progress have completed.

Stopping a connection has no effect on its ability to send messages. A call to stop on a connection that has already been stopped is ignored.

A call to stop must not return until delivery of messages has paused. This means that a client can rely on the fact that none of its message listeners will be called and that all threads of control waiting for receive calls to return will not return with a message until the connection is restarted. The receive timers for a stopped connection continue to advance, so receives may time out while the connection is stopped.

If message listeners are running when stop is invoked, the stop call must wait until all of them have returned before it may return. While these message listeners are completing, they must have the full services of the connection available to them.

Parameters:
p_xenv the local call environment. The default value is NULL.
f_xflags the flags that allow control over the reference type and other internal matters. The default value is xmog_base::GLOBAL.
Returns:


The documentation for this class was generated from the following file:
Generated on Fri Jun 16 10:19:46 2006 for JMS Courier for C++ by  doxygen 1.4.1