Skip navigation.
Downloads | Product Documentation | Support

Programming WebLogic Server J2EE Connectors

# Transaction Management

The following sections describe the various types of transaction levels supported by the WebLogic implementation of the J2EE Connector Architecture and explain how to specify the transaction levels in the resource adapter RAR archive.

- Supported Transaction Levels
- Specifying the Transaction Levels in the RAR Configuration
- Transaction Management Contract

# Supported Transaction Levels

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

The WebLogic Server J2EE Connector Architecture implementation utilizes the WebLogic Server Transaction Manager implementation and supports resource adapters having the following transaction support levels (as described in the J2EE Connector Specification, Version 1.0 Final Release):

- XA Transaction support—allows a transaction to be managed by a transaction manager external to a resource adapter (and therefore external to an EIS). A resource adapter defines the type of transaction support by specifying the transaction-support element in the ra.xml file; a resource adapter can only support one type. 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—allows an application server to manage resources, which are local to the resource adapter. Unlike XA transaction, it cannot participate in a two-phase commit protocol (2PC). A resource adapter defines the type of transaction support by specifying the transaction-support element in the resource adapter ra.xml file; a resource adapter can only support one type.

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, which is configured to use Local Transaction Suport, is made 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.

Note: Refer to the following Sun Microsystems documentation for information on the ra.xml document type definition: http://java.sun.com/dtd/connector_1_0.dtd

- No Transaction support—if a resource adapter is configured to use No Transaction support, the resource adapter may 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.

For more information on supported transaction levels, see the "Transaction Management" chapter in the J2EE Connector Specification, Version 1.0 Final Release (http://java.sun.com/j2ee/download.html#connectorspec).

# Specifying the Transaction Levels in the RAR Configuration

The resource adapter specifies which kind of transaction it supports in the ra.xml deployment descriptor file provided by Sun Microsystems. For instructions on specifying the transaction level type in the RAR, refer to Configuring the Transaction Level Type in Configuration.

Note: Refer to the following Sun Microsystems documentation for information on the ra.xml document type definition: http://java.sun.com/dtd/connector_1_0.dtd

# Transaction Management Contract

In many cases, a transaction (termed local transaction) is limited in scope to a single EIS system, and the EIS resource manager itself manages such a transaction. While an XA transaction (or global transaction) can span multiple resource managers. This form of transaction requires transaction coordination by an external transaction manager, typically bundled with an application server. A transaction manager uses a two-phase commit protocol (2PC) to manage a transaction that spans multiple resource managers (EISes). It uses one-phase commit optimization if only one resource manager is participating in an XA transaction.

The J2EE Connector Architecture defines a transaction management contract between an application server and a resource adapter (and its underlying resource manager). The transaction management contract extends the connection management contract and provides support for management of both local and XA transactions. The transaction management contract has two parts, depending on the type of transaction.

- JTA XAResource based contract between a transaction manager and an EIS resource manager
- Local transaction management contract

These contracts enable an application server such as WebLogic Server to provide the infrastructure and runtime environment for transaction management. Application components rely on this transaction infrastructure to support the component-level transaction model.

Because EIS implementations are so varied, the transactional support must be very flexible. The J2EE Connector Architecture imposes no requirements on the EIS for transaction management. Depending on the implementation of transactions within the EIS, a resource adapter may provide:

- No transaction support at all—this is typical of legacy applications and many back-end systems.
- Support for only local transactions
- Support for both local and XA transactions

WebLogic Server supports all three levels of transactions, ensuring its support of EISes at different transaction levels.