Creating a session in a JMS application
To create a session in JMS 1.0, a JMS application uses the createSession() method of a Connection object.
The createSession() method has two parameters:
- A parameter that specifies whether the session is transacted or not transacted
- A parameter that specifies the acknowledgment mode for the session
Session session;
.
boolean transacted = false;
session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
When a JMS session is created, the IBM® MQ classes for JMS creates a connection handle (Hconn) and starts a conversation with the queue manager.
A Session object, and any MessageProducer or MessageConsumer object created from it, cannot be used concurrently by different threads of a multithreaded application. The simplest way of ensuring that these objects are not used concurrently is to create a separate Session object for each thread.
This mechanism can also be used to supply an authentication token, see Obtaining an authentication token from
your chosen token issuer.