Distributed transactions are supported for topics as well as queues as long as the data store used is able to participate in distributed transactions. FioranoMQ supports the use of RDBMS as the data store for messages which needs to be used in XA scenarios. Fiorano's File-based data store cannot be used for destinations that need to be used in XA.
FioranoMQ XA implementation does provide support for local transactions as well. This implies that when a new XA session is created, it has a local transaction context. This local transaction context ends when the XA session gets associated with a global transaction context. XAResource associated with the session starts a new distributed transaction (XAResource.start). When the global transaction ends - (XAResource.end() or XAResource.rollback()) - xasession automatically switches back to the local transaction context where the JMS session of the xa session can be used as a transacted JMS session, invoking its commit/rollback methods.
The behavior of createSession call on the XAConnection object is undefined in the JTA specifications.
Session session = xaConnection.createSession(boolean transacted, int ackMode);
- boolean transacted: usage undefined.
- int ackmode: usage undefined.
FioranoMQ behaves in the following way when it encounters a createSession (or createTopicSession/createQueueSession ) on the xaConnection (or XATopicConnection/XAQueueConnection) object:
It returns the session (or topicsession/queueSession) object whose behavior is defined entirely by the specified parameters. For example, in the following call a transacted (non-xa) session object is returned, which can take part in the JMS transactions.
xaConnection.createSession(true, 0);
All transactions are rolled back on server startup or on application close.
If a FioranoMQ client terminates after a transaction has successfully ended, (XAResource.TMSuccess)/suspended (XAResource.TMSUSPEND)/ prepared (returned with an XAResource.XA_OK flag), then this transaction can be used from the same status (prepared, ended or suspended), upon client re-activation. Similarly, if a FioranoMQ Server terminates when any ended/suspended/prepared transactions are active then, upon restart, FioranoMQ clients remain unaffected and can continue working on the transaction.
RDBMS based topics, on which messages are published in a transaction get locked in the 'prepare' call. No other transaction can be prepared in which messages published on locked topics. All Non-xa publishers publishing on a locked topic have to wait for the release of the lock to publish a message.