Skip navigation.
Downloads | Product Documentation | Support

Programming WebLogic Resource Adapters

# Transaction Management

The following sections discuss the system-level transaction management contract that is used for outbound communication from WebLogic Server to Enterprise Information Systems (EISes):

- Supported Transaction Levels
- Configuring Transaction Levels

For more information on transaction management, see Chapter 7 "Transaction Management" of the J2CA 1.5 Specification. For information about transaction management for inbound communication from EISes to WebLogic Server, see Transactional Inflow.

# Supported Transaction Levels

A transaction is a set of operations that must be committed together or not at all for the data to remain consistent and to maintain data integrity. Transactional access to EISes is an important requirement for business applications. The J2EE 1.5 Connector Architecture supports the use of transactions.

WebLogic Server utilizes the WebLogic Server Transaction Manager implementation and supports resource adapters having XA, local, or no transaction support. You define the type of transaction support in the `transaction-support` element in the ra.xml file; a resource adapter can support only one type. You can use the `transaction-support` element in the weblogic-ra.xml deployment descriptor to override the value specified in ra.xml. See Configuring Transaction Levels and transaction-support for details.

## XA Transaction Support

XA transaction support allows a transaction to be managed by a transaction manager external to a resource adapter (and therefore external to an EIS). When an application component demarcates an EIS connection request as part of a transaction, the application server is responsible for enlisting the XA resource with the transaction manager. When the application component closes that connection, the application server cleans up the EIS connection once the transaction has completed.

## Local Transaction Support

Local transaction support allows WebLogic Server to manage resources that are local to the resource adapter. Unlike XA transaction, local transaction generally cannot participate in a two-phase commit protocol (2PC). The only way a local transaction resource adapter can be involved in a 2PC transaction is if it is the only local transaction resource involved in the transaction and if the WebLogic Server Connector container uses a Last Resource Commit Optimization whereby the outcome of the transaction is governed by the resource adapter's local transaction.

A local transaction is normally started by using the API that is specific to that resource adapter, or the CCI interface if it is supported for that adapter. When a resource adapter connection that is configured to use local transaction support is created and used within the context of an XA transaction, WebLogic Server automatically starts a local transaction to be used for this connection. When the XA transaction completes and is ready to commit, prepare is first called on the XA resources that are part of the XA transaction. Next, the local transaction is committed.

If the commit fails on the local transaction, the XA transaction and all the XA resources are rolled back. If the commit succeeds, all the XA resources for the XA transaction are committed. When an application component closes the connection, WebLogic Server cleans up the connection once the transaction has completed.

## No Transaction Support

If a resource adapter is configured to use no transaction support, the resource adapter can still be used in the context of a transaction. However, in this case, the connections used for that resource adapter are never enlisted in a transaction and behave as if no transaction was present. In other words, operations performed using these connections are made to the underlying EIS immediately, and if the transaction is rolled back, the changes are not undone for these connections.

# Configuring Transaction Levels

You specify a transaction support level for a resource adapter in the J2EE standard resource adapter deployment descriptor, ra.xml. To specify the transaction support level:

- For No Transaction, add the following entry to the ra.xml deployment descriptor file: <transaction-support>NoTransaction</transaction-support>
- For XA Transaction, add the following entry to the ra.xml deployment descriptor file: <transaction-support>XATransaction</transaction-support>
- For Local Transaction, add the following entry to the ra.xml deployment descriptor file: <transaction-support>LocalTransaction</transaction-support>

The transaction support value specified in the ra.xml deployment descriptor is the default value for all Connection Factories of the resource adapter. You can override this value for a particular Connection Factory by specifying a value in the transaction-support element of the weblogic-ra.xml deployment descriptor.

The value of transaction-support must be one of the following:

- NoTransaction
- LocalTransaction
- XATransaction

For more information on specifying the transaction level in the `ra.xml` deployment descriptor, see Section 17.6 "Resource Adapter XML Schema Definition" of the J2CA 1.5 Specification. For more information on specifying the transaction level in the `weblogic-ra.xml` deployment descriptor, see weblogic-ra.xml Schema.