Programming WebLogic Resource Adapters
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.
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 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 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.
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.
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.
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.