Tuning the session
When connecting to a JMS session, you should strive to reuse an existing session as it can be quite expensive and time-consuming to create a new. Note that reusing an existing session is only fully acceptable within a thread as the session in not thread-safe.
In order to realize the requirements of guaranteed delivery, JMS defines an acknowledgement mechanism that is used in the communication between the clients. The behavior of this mechanism can be controlled by selecting an appropriate acknowledgement mode. The JMS specification provides the following three modes:
CLIENT_ACKNOWLEDGE
: Any client code must acknowledge the message by calling one of its acknowledge methods. Failing to do this may lead to a serious buildup of resources on the server.AUTO_ACKNOWLEDGE
: A client's consumption of a message will be automatically acknowledged immediately when it's received, either returning from thereceive
method or calling theprocess
method on a message listener.DUPS_OK_ACKNOWLEDGE...