Obtaining a session
Once a connection is made, use the createQueueSession method on the QueueConnection to obtain a session.
The method takes two parameters:
- A boolean that determines whether the session is transacted or non-transacted.
- A parameter that determines the acknowledge mode.
The simplest case is that of the non-transacted session with AUTO_ACKNOWLEDGE, as shown in the following code fragment:
QueueSession session; boolean transacted = false; session = connection.createQueueSession(transacted, Session.AUTO_ACKNOWLEDGE);A connection is thread safe, but sessions (and objects that are created from them) are not. The recommended practice for multithreaded applications is to use a separate session for each thread.
uj24410_