WebSphere MQ class: MQConnection
java.lang.Object | +----com.ibm.mq.jms.MQConnection |
A JMS Connection is a client's active connection to its JMS provider.
See also: QueueConnection, TopicConnection, XAQueueConnection, and XATopicConnection
public void close() throws JMSException
Because a provider may allocate some resources outside the JVM on behalf of a Connection, clients should close them when they are not needed. You cannot rely on garbage collection to reclaim these resources eventually, because this may not occur soon enough. There is no need to close the sessions, producers, and consumers of a closed connection.
Closing a connection causes any of its sessions' in-process transactions to be rolled back. In the case where a session's work is coordinated by an external transaction manager, when using XASession, a session's commit and rollback methods are not used and the result of a closed session's work is determined later by a transaction manager. Closing a connection does NOT force an acknowledge of client acknowledged sessions.
WebSphere MQ JMS keeps a pool of WebSphere MQ hConns available for use by Sessions. Under some circumstances, Connection.close() clears this pool. If an application uses multiple Connections sequentially, it is possible to force the pool to remain active between JMS Connections. To do this, register an MQPoolToken with com.ibm.mq.MQEnvironment for the lifetime of your JMS application. For details, see Connection pooling and MQEnvironment.
public java.lang.String getClientID() throws JMSException
Get the client identifier for this connection. The client identifier can either be preconfigured by the administrator in a ConnectionFactory, or assigned by calling setClientId.
public ExceptionListener getExceptionListener() throws JMSException
Get the ExceptionListener for this Connection.
public ConnectionMetaData getMetaData() throws JMSException
Get the metadata for this connection.
public void setClientID(java.lang.String clientID) throws JMSException
Set the client identifier for this connection.
WebSphere MQ Event Broker note |
---|
This method always throws an IllegalStateException when you make a direct connection to WebSphere MQ Event Broker. |
public void setExceptionListener(ExceptionListener listener) throws JMSException
Set an exception listener for this connection.
public void start() throws JMSException
Start (or restart) a Connection's delivery of incoming messages. Starting a started session is ignored.
public void stop() throws JMSException
Used to stop a Connection's delivery of incoming messages temporarily. It can be restarted using its start method. When stopped, delivery to all the Connection's message consumers is inhibited. Synchronous receives are blocked, and messages are not delivered to message listeners.
Stopping a session has no affect on its ability to send messages. Stopping a stopped session is ignored.