13.2. XA Transactions

13.2.1. Requirements for Using Kodo with XA Transactions
13.2.2. Configuring Kodo to Utilize XA Transactions

The X/Open Distributed Transaction Processing (X/Open DTP) model, designed by Open Group (a vendor consortium), defines a standard communication architecture that provides the following:

The X/Open DTP XA standard defines the application programming interfaces that a resource manager uses to communicate with a transaction manager. The XA interfaces enable resource managers to join transactions, to perform two-phase commit, and to recover in-doubt transactions following a failure.

13.2.1. Requirements for Using Kodo with XA Transactions

Kodo JDO Enterprise Edition supports XA-compliant transactions when used in a properly configured managed environment. The following components are required:

  • A managed environment that provides an XA compliant transaction manager. Examples of this are application servers such as JBoss and WebLogic.

  • Instances of a javax.sql.XADataSource for each of the datasources that Kodo will use.

13.2.2. Configuring Kodo to Utilize XA Transactions

In order for Kodo to participate in a distributed transaction, the following configuration tasks needs to be accomplished:

  • Configure Kodo to use your third-party javax.sql.XADataSource See Section 4.2, “Using a Third-Party DataSource” on using a third-party data source for details.

  • Configure a separate data source for non-transactional connections. This should not be an XA data source. Kodo needs to have access to a data source that will not be enlisted in an XA transaction for things like obtaining database sequence numbers for datastore identity, which should not be part of Kodo's transaction.

    See Section 4.1, “Using the Kodo JDO DataSource” or Section 4.2, “Using a Third-Party DataSource” for information on how to configure the non-transactional data source. Just remember to use the "2" version of all the connection configuration properties: kodo.Connection2DriverName, kodo.Connection2UserName, javax.jdo.option.ConnectionFactory2Name, and so forth.

  • Kodo needs to be aware that the XA data source is automatically enlisted in the distributed transaction. Set the kodo.jdbc.DataSourceMode configuration property to enlisted.

Example 13.2. XA Configuration

javax.jdo.option.ConnectionFactoryName: java:/OracleXASource
kodo.Connection2UserName: scott
kodo.Connection2Password: tiger
kodo.Connection2URL: jdbc:oracle:thin:@CROM:1521:JDODB
kodo.Connection2DriverName: oracle.jdbc.driver.OracleDriver
kodo.ConnectionFactory2Properties: MaxActive=20, MaxIdle=10
kodo.TransactionMode: managed
kodo.jdbc.DataSourceMode: enlisted