A session may optionally be specified as transacted. The message consumes and producers created by a transacted session have a special acknowledge mode, whereby messages must be acknowledged using the commit and rollback methods of the session. There is always a current transacted, i.e. as soon as a set of messages have been committed or rolled back, the session automatically starts a new transaction. The session transaction is local in the sense that it can not be coordinated with any other resources than the session.
Each transacted session supports a single series of transactions. A transaction groups a set of produced messages and a set of consumed messages into an atomic unit of work. In effect, transactions organize a session's input message stream and output message stream into series of atomic units. When a transaction commits, its atomic unit of input is acknowledged and its associated atomic unit of output is sent. If a transaction rollback is done, its produced messages are destroyed and its consumed messages are automatically recovered.
A conceptual picture of a transacted session is to think that the session has a "bucket" with messages sent by the session's message producers and message acknowledgements performed by the session's message consumers. Sent messages and message acknowledgements are added to the bucket as the producers and consumers do work. When the session is committed this whole bucket (atomic unit of work) is sent to the JMS server and made "real". In case of rollback, the messages in the bucket are discarded and the acknowledged messages are recovered.
Transacted
Session Sample Program
This sample program illustrates how to use a transacted session.
Domain Unification Sample Program
This sample program illustrates the domain unification introduced in revision 1.1 of the JMS specification.