Using Transactions with JMS

You learned about the Session interface back in the “The JMS Interfaces” section earlier. When using a transacted session, all messages that are produced and sent are performed as a unit of work. If anything happens that causes a need to roll back the transaction, all messages that are produced within that transaction are destroyed, and all the messages that are sent are recovered. This allows a client to treat a group of messages as an atomic unit. Either all of them succeed or none of them do.

You can use the session’s commit or rollback methods to cause a session to succeed or fail, respectively. After a transaction is complete by calling either of the two methods, a new transaction is automatically created for ...

Get Special Edition Using Enterprise JavaBeans™ 2.0 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.