EAServer’s transaction processing model  Chapter 3: Managing Applications and Packages in EAServer Manager

Chapter 2: Understanding Transactions and Component Lifecycles

EAServer Transaction Manager

The EAServer Transaction Manager supports the specifications for the Java Transaction API (JTA) 1.0 and the OTS/XA standards. The Transaction Manager supports the integrated functionality of these transaction coordinators: shared connections, OTS/XA, and JTS/JTA, and includes:

The EAServer Transaction Manager enables EAServer to control the scope and duration of transactions across multiple resource managers. It also provides the ability to synchronize transactions and to communicate with other transaction managers using CORBA OTS. Connections and resources are dynamically enlisted into a transaction when they are requested.

Two-phase commit ensures that all changes to recoverable resources (for example, multiple database servers) occur automically, and the failure of any resource to complete causes all other resources to undo changes. Two-phase commit consists of a prepare phase and an execution phase. In the prepare phase, the transaction coordinator validates that all resources are available. In the execution phase, the transaction coordinator executes all updates to the resources.

You can define components and component methods so that the transaction coordinator automatically handles transactions (implicit control). You can also write component and client code to manage transactions (explicit control).

EAServer implements the javax.transaction.TransactionManager interface, which allows it to control transaction boundaries, and to manage the interaction between Java and Encina transaction objects.

EAServer’s implementation of the javax.transaction.Transaction interface enables it to manage a set of javax.transaction.xa.XAResource resources that participate in a transaction. To determine the boundaries and outcome for these transactions, EAServer uses the CosTransaction::Resource interface.

StepsConfiguring EAServer to use JTS/JTA transactions

  1. In EAServer Manager, highlight the server you want to configure.

  2. Choose File | Server Properties.

  3. In the Properties dialog box, select the Transactions tab.

  4. Select JTS/JTA Transactions.

A component with the JTS transaction attribute enabled follows the standard component lifecycle as described in “Component lifecycles”.

Resource recovery and transaction logging

Resource recovery is a configurable option that provides object persistence and recovery operations. Basic persistence is achieved by writing transactions to a transaction log that contains all the information necessary to re-create the transaction. Persistence is supported for the CosTransactions::Resource and CosTransactions::Synchronization objects. Recovery is supported for JDBC connectors and native type resources that are registered with EAServer. When EAServer starts, the recovery manager is called, which reads the transaction log and starts transaction recovery.

NoteRecovery operations can be performed only for transaction logs that were created for EAServer version 5.0 or later.

A transaction log provides enhanced debugging and integrates with the standard EAServer logging functionality. Monitoring functionality is also provided, which allows you to use EAServer Manager to view statistics, such as the total number of transactions, currently active transactions, average duration of transactions, failed transactions, and remotely started transactions.

When EAServer starts, the TransactionLogManager verifies the transaction log’s integrity, automatically does necessary repairs, then runs the transaction log defragmenter. This helps to allocate space for new transactions. The recovery manager passes transaction information to the TransactionLogManager, which is responsible for storing and deleting the transaction record from the transaction log.

Recovering XA resources registered by user components

In this version of EAServer, you cannot directly recover XA resources that are registered by user components. However, you can enable EAServer to accomplish this task by using the following technique:

  1. Create a wrapper DataSource class; for example, WrapperDataSource.

  2. WrapperDataSource.getXAConnection() returns an XAConnection class that corresponds to the XA connection with the resource.

  3. Create an XA-type connection cache, and set its class name to the WrapperDataSource class that you created.

Once these steps are implemented, EAServer takes care of the recovery process. This is useful when using a third-party JMS service with XA resources.

Transaction interoperability

EAServer Transaction Manager provides transaction interoperability in accordance with the OTS specifications.

When EAServer runs in JTS mode, it can share the transaction coordinator across multiple servers. If a transactional component on one server invokes a component method on another server, both components can participate in the same transaction. Also, a client can invoke components on multiple servers that all participate in the same transaction. This feature is useful for load balancing.

Figure 2-4 illustrates a scenario in which a client calls a component method on Server A, which calls a component method on Server B. Server A and Server B use different databases. To ensure that all the database updates occur within the scope of a single transaction, EAServer passes the transaction context between servers.

Figure 2-4: Transaction interoperability

Figure 2-5 illustrates an example where a client calls components on multiple servers, which all participate in the same transaction. The client manages the transaction by calling component methods on each server and passing the transaction context.

Figure 2-5: Server to server

Resource manager

The EAServer Transaction Manager includes an integrated resource manager that supports JDBC 1.0, JDBC 2.0, connectors, and XA resources for both Java and C++. The resource manager allows you to dynamically register resources and synchronize coordinators in accordance with OTS specification for CosTransactions. The resource manager is based on the functionality of both the Java Connection Manager and the Jaguar Connection Manager, which allows you to easily integrate new and existing resources. In future EAServer versions, customers will be able to use the resource manager to create and configure resources that EAServer can use.

Enlisting XA resources with Transaction Manager

When EAServer is running in two-phase commit mode, which is the default for version 5.0 or later, you can enlist XA resources with EAServer Transaction Manager.

StepsEnlisting XA resources

To enlist an XA resource into a current EAServer transaction:

  1. Get the instance of Transaction Manager:

    javax.transaction.TransactionManager tm = com.sun.jts.jta.TransactionManager.getTransactionManagerImpl();
  2. Get the instance of the transaction:

    javax.transaction.Transaction trans = tm.getTransaction();
  3. Register the XA resource with the transaction:


EAServer manages this XA resource with respect to its transaction boundaries.

Copyright © 2005. Sybase Inc. All rights reserved. Chapter 3: Managing Applications and Packages in EAServer Manager