Managed IBM MQ XA transactions through XMS

Managed IBM MQ XA transactions can be used through XMS.

To use XA transactions through XMS, a transacted session has to be created. When XA transaction is in use, the transaction control is through Distributed Transaction Coordinator (DTC) global transactions and it is not though XMS sessions. When using XA transactions, Session.commit or Session.rollback cannot be issued on the XMS session. Instead, use the Transscope.Commit or Transscope.Rollback DTC methods commit or roll back the transactions. If a session is used for XA transaction, the producer or consumer that are created using the session must be a part of the XA transaction. They cannot be used for any operations outside the XA transaction scope. They cannot be used for operations like Producer.send or Consumer.receive outside the XA transaction.

An IllegalStateException exception object is thrown if:

  • XA transacted session is used for Session.commit or Session.rollback.
  • Producer or consumer objects which are once used in XA transacted session are used out side the XA transaction scope.

The XA transactions are not supported in asynchronous consumers.

Note:
  1. A close might be issued on the Producer, Consumer, Session, or Connection object before the XA transaction commit. In which cases the messages in the transaction are rolled back. Similarly, if the connection is broken before the XA transaction commit, all the messages in the transaction are rolled back. For a Producer object, a rollback means that the messages are not put on the queue. For a Consumer object, a rollback means that the messages remain on the queue.
  2. If a Producer object puts a message with TimeToLive in the TransactionScope and a commit is issued after the time is elapsed, the message can expire before the commit is issued. In this case, the message is not made available to Consumer objects.
  3. Session objects are not supported across threads. The use of transactions with Session objects that are shared across threads is not supported.

Parent topic: Writing XMS applications