This release of JMS supports distributed (global) transactions. As mentioned in the concepts guide, a distributed transaction goes beyond a transacted session by allowing the task of sending or acknowledging messages to be coordinated with other tasks executing in a distributed system. The transactions coordinator, which is part of JTS is called a resource manager.
The resource in JMS is an XAResource, which can be obtained using the
getXAResource
method of the
XASession.
The XAResource interface supports various method, which the coordinator
must call to manage the resource and ensure proper execution of the
transaction.
The first part of this example illustrates how to create a router that consumes messages from a destination residing in one JMS server, and produces those messages to a destination in another JMS server. The second part of the example shows how to do this using a distributed transaction to ensure that consuming and producing each routed message happens as one atomic unit of work.