When you use the XA feature, the transaction manager uses an XA resource instance to prepare and coordinate each transaction branch, and then properly commit or roll back all transaction branches.
Key components of the XA feature include XA data sources, XA connections, XA resources, and transaction IDs.
XA data sources
XA data sources are extensions of connection pool data sources and other data sources and are similar to those data sources in concept and functionality.
Each resource manager has an XA data source instance for distributed transactions. Typically, an XA data source instance is created in the intermediate-layer software.
XA data sources generate XA connections.
XA connections
XA connections are an extension of pooled connections and are similar to the latter in concept and functionality. XA connections are encapsulated with physical database connections. Each connection instance is a temporary handle of these physical connections.
An XA connection instance corresponds to only one session, although the session can be used by multiple logical connection instances in sequence, such as pooled connection instances.
Typically, you can obtain an XA connection instance from an XA data source instance in the intermediate-layer software. If a distributed transaction involves multiple sessions in the same database, it can get multiple XA connection instances from a single XA data source instance.
XA connections generate OracleXAResource instances and JDBC connection instances.
XA resources
The transaction manager uses XA resources to coordinate transaction branches for distributed transactions.
Typically, in the intermediate-layer software, you can obtain one OracleXAResource instance from each XA connection instance. OracleXAResource instances and XA connection instances are in one-to-one mapping. Similarly, OracleXAResource instances and sessions are in one-to-one mapping.
Typically, the intermediate-layer component hands over the OracleXAResource instances to the transaction manager for the coordination of distributed transactions.
Each OracleXAResource instance corresponds to one session, so the OracleXAResource instance is associated with only one active transaction branch at any given time, but may be associated with other suspended transaction branches.
Each OracleXAResource instance can process its associated session transaction branches, including starting, ending, preparing, committing, and rolling back the transaction branches.
The preparation step is the first step in a two-phase commit operation. In this step, the transaction manager issues the PREPARE command to each OracleXAResource instance. When the transaction manager confirms that each transaction branch has been prepared for the operation, it issues the COMMIT command to each OracleXAResource instance to commit all changes.
Transaction ID
A transaction ID is used to identify a transaction branch. Each transaction ID consists of a transaction branch ID component and a distributed transaction ID component. This is the way branches are associated with distributed transactions. All OracleXAResource instances associated with a given distributed transaction have transaction IDs that contain the same distributed transaction ID component.
OracleXAResource.ORATRANSLOOSE
Uses the transaction ID xid to start a loosely coupled transaction.