Obtaining a session

Once a connection has been created, you can use the createQueueSession() method on the QueueConnection to obtain a session. The method takes two parameters:
  1. A boolean that determines whether the session is "transacted" or "non-transacted".
  2. A parameter that determines the "acknowledge" mode. This is used when the session is "non-transacted".
The simplest case is that where acknowledgements are used and are handled by JMS itself with AUTO_ACKNOWLEDGE, as shown in the following code fragment:
QueueSession session;
boolean transacted = false;
session = connection.createQueueSession(transacted, Session.AUTO_ACKNOWLEDGE);
Figure 1. Obtaining a session once a connection is created
Diagram showing how to use createQueueSession() methon on the QueueConnection to obtain a session, once a QueueConnection has been created. This implements the createSender() and createReceiver() methods on QueueSession.

Terms of use | WebSphere software

(c) Copyright IBM Corporation 2004, 2005. All rights reserved.