3.3. Sessions

A session is a single-threaded context for producing and consuming messages. You use sessions to create message producers, message consumers, and messages. Sessions serialize the execution of message listeners; for details, see Section 3.5.1 on page 22.

A session provides a transactional context with which to group a set of sends and receives into an atomic unit of work. For details, see Section 5.2.2 on page 64.

Sessions, like connections, come in two forms, implementing either the QueueSession or the TopicSession interface. For example, if you created a TopicConnection object, you use it to create a TopicSession:

TopicSession topicSession =
  topicConnection.createTopicSession(false,
  Session.AUTO_ACKNOWLEDGE);

The first argument ...

Get Java™ Message Service API Tutorial and Reference: Messaging for the J2EE™ Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.