WebLogic Messaging API Class Library

IConnection.Close�Method�

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. Similarly, there is no need to Close a connection if its parent context has been closed with CloseAll.

When this method is invoked, it does 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 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 (this type of transaction is not supported in the first release of the WebLogic JMS .NET client).

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 throws an IllegalStateException. Closing a closed connection does NOT throw an exception.

void�Close();

Exceptions

Exception TypeCondition
MessageExceptionif JMS fails to Close the connection due to some internal error. For example, a failure to release resources or to Close a socket connection can cause this exception to be thrown.

See Also

IConnection Interface | WebLogic.Messaging Namespace