Creating XA Connections
To create an XA connection, a client must first acquire an XAConnectionFactory
. It can then call createXAConnection()
to create an XAConnection
to the event broker.
For information on how to programmatically create or to look up Connection Factories and how to establish connections, refer to Establishing Connections.
A SolXAConnectionFactory
inherits attributes from SolConnectionFactory
, therefore, to use XA transactions, you must set the following SolConnectionFactory
attributes:
- The
direct-transport
transport property in the JNDI Connection Factory must be set tofalse
so that a Guaranteed message delivery mode is used (refer to Direct Transport). A Guaranteed message delivery mode must be used because only Guaranteed messages (that is, messages with Persistent or Non‑Persistent delivery modes) can be published or received through transactions; Direct messages cannot be used in XA transactions or local transactions. - The
xa
JMS data connection property must be set totrue
to permit the Connection Factory to use XA transactions (refer to XA).
Creating XA Sessions
Once a client has established an XA connection to an event broker, it can create one or more XA Sessions.
Within an XA Session, individual atomic transactions, also known as a transaction branches, can be created. Although an XA Session can contain multiple transaction branches (as identified by their unique Xids), only one transaction branch can active at a time in an XA Session.
To create an XA Session, call XASession.createXASession()
.
XAResource.start(...)
can also be used to resume a suspended transaction.
Starting XA Transactions
Unlike Session-based transactions, once an XA Session is created, a transaction does not automatically begin within that XA Session. To start a transaction within an XA Session, a client must obtain the XAResource to be used by the XA Session and an Xid for the transaction. Then the XAResource.start(...)
method can be invoked to start that particular transaction branch. (Typically, a Transaction Manager obtains an XAResource for each resource participating in a distributed or global transaction.) For more information, refer to Performing XA Transaction Operations.