JMS sessions

 

+

Search Tips   |   Advanced Search

 

A JMS session is used to create message producers and message consumers for a single JMS provider. It is created from a JMS Connection object.

It is also used to define the scope of local transactions. It can group multiple send and receive interactions with the JMS provider into a single unit of work. However, the unit of work only spans the interactions performed by message producers or consumers created from this Session object. A transacted session can complete a transaction using the commit or rollback methods of the Session object. Once the current transaction has been completed, a new transaction is automatically started.

Session objects do not support concurrent use. They cannot be accessed at the same time by multiple threads within a JMS client application. If a JMS client requires one thread to produce messages while another thread consumes them, the JMS specification recommends that the JMS client uses separate Sessions for each thread.

The session interfaces defined within the JMS specification...

Common interface Domain-specific interfaces

Point-to-Point Publish/Subscribe
Session QueueSession TopicSession

The code required to create a Session object...

// Create a non-transacted session
Session session = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);

Next