43.4. Methods

The following methods are defined in the interface javax.jms.Session.


public void close()

Closes the session.

Since a provider may allocate some resources on behalf of a session outside the JVM, clients should close the 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 producers and consumers of a closed session.

This call will block until a receive call or message listener in progress has completed. A blocked message consumer receive call returns null when this session is closed.

Closing a transacted session must roll back the transaction in progress.

This method is the only Session method that can be called concurrently. ...

Get Java™ Message Service API Tutorial and Reference: Messaging for the J2EE™ Platform now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.