web server - Borland Technical Publications

web server - Borland Technical Publications web server - Borland Technical Publications

techpubs.borland.com
from techpubs.borland.com More from this publisher
12.11.2014 Views

Transaction manager services Transaction Manager for two-phase commit, you must set the “Allow unrecoverable completion” property to true in “Properties” for the Transaction Manager as displayed under the Partition in the BES Management Console. Alternatively, you can set system property EJBAllowUnrecoverableCompletion for the partition. The OTS engine exists in a separate address space. It provides a complete solution for distributed transactional CORBA applications. Implemented on top of the VisiBroker ORB, the OTS engine simplifies the complexity of distributed transactions by providing an essential set of services - including a transaction service, recovery and logging, integration with databases, and administration facilities - within one, integrated architecture. Distributed transactions and two-phase commit Note The Borland EJB Container supports distributed transactions. Distributed transactions are those transactions that cross systems, platforms, and Java Virtual Machines (JVMs). Transactions that manipulate data across multiple resources use a two-phase commit process. This process ensures that the transaction correctly updates all resources involved in the transaction. If it cannot update all resources, then it updates none of the resources. Although support is provided by BES for two-phase commit transactions, they are inherently expensive due to number of remote procedure calls (RPCs) and should be used only when needed. See “When to use two-phase commit transactions” on page 170. There are two steps to a two-phase commit. The first step is the preparation phase. In this phase the transaction service requests that each resource involved in the transaction readies its updates and signal to the transaction service whether it can commit the updates. The second step is the commit phase. The transaction service initiates the actual resource updates only when all resources have signaled that they can complete the update process. Should any resource signal they cannot perform updates, the transaction service instructs all other resources to rollback all updates involved in the transaction. The Transaction Manager and OTS engine support both heterogeneous distributed (two-phase commit) transactions and two-phase commit for homogeneous resources. By default, the Transaction Manager does not allow multiple resources to participate in a global transaction, but it can be configured to allow multiple resource participation through its support for unrecoverable transaction completion. This can be enabled on the Transaction Manager by setting either “Allow unrecoverable completion” option from the Management Console (right-click the Transaction Manager and select “Properties”), or the Partition system property EJBAllowUnrecoverableCompletion. When unrecoverable transaction completion is enabled, the container makes a one-phase commit call on each participating resource during the transaction commit process. Care must taken when enabling unrecoverable transaction completion; as the name suggests, no recovery is available when a failure occurs prior to transaction completion, which may lead to inconsistent states in participating resources. To support heterogeneous two-phase commit transactions, the OTS engine must integrate with XA support in the underlying resources. With availability of XA-enabled JDBC drivers from DBMS vendors and JMS support provided by message service providers, the EJB container and OTS engine allow multiple resources to participate in a single transaction. Two-phase commit for homogeneous databases requires some configuration of the DBMS servers. While the container controls the commit to the first database, the DBMS server controls the commits to the subsequent databases using the DBMS's built-in transaction coordinator. For more information, see your vendor's manual for the DBMS server. Chapter 19: Transaction management 169

Transaction manager services When to use two-phase commit transactions One of the basic principals of building high performance distributed applications is to limit the number of remote procedure calls (RPCs). The following explains typical situations; when and when not to use two-phase commit transactions. Avoiding a twophase commit transaction when it is not needed, therefore avoiding unnecessary RPCs involving JTA XAResource objects and the OTS engine, greatly improves your application's performance. Using multiple JDBC connections for access to multiple database resources from a single vendor in the same transaction In scenarios involving multiple databases from a single vendor, it is often possible to avoid using two-phase commit. You can access one database and use it to access the second database by tunneling access through the connection to the first database. Oracle and other DBMSs provide this capability. In this case the BES Partition can be configured with only one JDBC connection to the “fronting” database. Access to the “backing” database is tunneled through the first JDBC connection. Using multiple JDBC connections to the same database resource in the same transaction When multiple JDBC connections to the same database are obtained and used by distributed participants within a single transaction, a two-phase commit can be avoided. The JDBC connections, as expected, need to be obtained from a XA datasource. But, rather than performing a two-phase commit, a one-phase commit can be used to complete the transaction since only a single resource is involved. This is achieved by using the Transaction Manager rather than the OTS engine. An alternative is to collocate all EJBs involved in the transaction, rather than having them deployed in distributed Partitions. In this case, a non-XA datasource is used and no two-phase commit is required. Note Using multiple disparate resources in a single transaction In this case there is a need for a two-phase commit transaction. This situation arises when, for example, you are running a single transaction against both Oracle and Sybase, or if you have a transaction that includes access to an Oracle database and a JMS provider, such as MQSeries. In the latter case, the transaction is coordinated using JTA XAResource object, obtained from Oracle via JDBC and MQSeries via JMS, and enables both resources to participate in the two-phase commit transaction completion. It is worth noting that two-phase commit capabilities (provided by the OTS engine), are only needed when a single transaction involves access to multiple incompatible resources. In order to utilize the OTS engine as the default transaction service, the Transaction Manager must be stopped first. 170 BES Developer’s Guide

Transaction manager services<br />

When to use two-phase commit transactions<br />

One of the basic principals of building high performance distributed applications is to<br />

limit the number of remote procedure calls (RPCs). The following explains typical<br />

situations; when and when not to use two-phase commit transactions. Avoiding a twophase<br />

commit transaction when it is not needed, therefore avoiding unnecessary RPCs<br />

involving JTA XAResource objects and the OTS engine, greatly improves your<br />

application's performance.<br />

Using multiple JDBC connections for access to multiple database<br />

resources from a single vendor in the same transaction<br />

In scenarios involving multiple databases from a single vendor, it is often possible to<br />

avoid using two-phase commit. You can access one database and use it to access the<br />

second database by tunneling access through the connection to the first database.<br />

Oracle and other DBMSs provide this capability. In this case the BES Partition can be<br />

configured with only one JDBC connection to the “fronting” database. Access to the<br />

“backing” database is tunneled through the first JDBC connection.<br />

Using multiple JDBC connections to the same database resource in the<br />

same transaction<br />

When multiple JDBC connections to the same database are obtained and used by<br />

distributed participants within a single transaction, a two-phase commit can be<br />

avoided. The JDBC connections, as expected, need to be obtained from a XA<br />

datasource. But, rather than performing a two-phase commit, a one-phase commit can<br />

be used to complete the transaction since only a single resource is involved. This is<br />

achieved by using the Transaction Manager rather than the OTS engine. An alternative<br />

is to collocate all EJBs involved in the transaction, rather than having them deployed in<br />

distributed Partitions. In this case, a non-XA datasource is used and no two-phase<br />

commit is required.<br />

Note<br />

Using multiple disparate resources in a single transaction<br />

In this case there is a need for a two-phase commit transaction. This situation arises<br />

when, for example, you are running a single transaction against both Oracle and<br />

Sybase, or if you have a transaction that includes access to an Oracle database and a<br />

JMS provider, such as MQSeries. In the latter case, the transaction is coordinated<br />

using JTA XAResource object, obtained from Oracle via JDBC and MQSeries via JMS,<br />

and enables both resources to participate in the two-phase commit transaction<br />

completion. It is worth noting that two-phase commit capabilities (provided by the OTS<br />

engine), are only needed when a single transaction involves access to multiple<br />

incompatible resources.<br />

In order to utilize the OTS engine as the default transaction service, the Transaction<br />

Manager must be stopped first.<br />

170 BES Developer’s Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!