They provide a gradient of classes of service. JMS allows ...
- Messages outside the unit of work
- Messages inside single phase latch (1PC)
- Messages inside two phase latch (2PC / XA)
The cost of each of them increases with a degree of reliability. Typically, you want to use the least cost method that the application requires. If you have a fake, expiring, fire and forget message (such as an exchange ticker event) that puts it in a unit of work, is wasteful. Similarly, if you need a transactional session, but JMS is your only resource manager, XA will be a waste.
On the other hand, if you need XA for some operations, this does not mean that you should use XA for all operations. For example, you might have one connection in which you support one session for XA transactions and another session for non-XA messaging. The first of these is receiving requests for lengthy processes and updating the database with process data. Another session is used to send periodic status updates. The connection should be XAConnection, but for performance purposes, you need both an XA and a non-XA session under it. You can also support separate connections, but this method allows you to exchange XA and non-XA messages in the same connection. For brokers with many connections, this optimization can be crucial.
Admittedly, this is not a very common use case, but it is still a valid case and useful enough to be included in the specification.
source share