BEA Logo BEA WebLogic Enterprise Release 5.0

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   WLE Doc Home   |   Transactions & Related Topics   |   Previous   |   Next   |   Contents   |   Index

Transaction Service

This topic includes the following sections:

This topic provides the information that programmers need to write transactional applications for the WebLogic Enterprise (WLE) system. Before you begin, you should read Introducing Transactions.

About the Transaction Service

WLE provides a Transaction Service that supports transactions in CORBA, EJB, and RMI applications. The Transaction Service provides:

For CORBA Java, EJB, and RMI applications, WLE also provides Sun Microsystems, Inc.'s javax.transaction package, which implements the Java Transaction API (JTA) for Java applications. For more information about the JTA, see Sun Microsystem's Java Transaction API (JTA) Specification (version1.0.1). For more information about the UserTransaction object that applications use to demarcate transaction boundaries, see UserTransaction API.

Capabilities and Limitations

This topic includes the following sections:

These sections describe the capabilities and limitations of the Transaction Service that supports CORBA and EJB applications:

Lightweight Clients with Delegated Commit

A lightweight client runs on a single-user, unmanaged desktop system that has irregular availability. Owners may turn their desktop systems off when they are not in use. These single-user, unmanaged desktop systems should not be required to perform network functions such as transaction coordination. In particular, unmanaged systems should not be responsible for ensuring atomicity, consistency, isolation, and durability (ACID) properties across failures for transactions involving server resources. WLE remote clients are lightweight clients.

The Transaction Service allows lightweight clients to do a delegated commit, which means that the Transaction Service allows lightweight clients to begin and terminate transactions while the responsibility for transaction coordination is delegated to a transaction manager running on a server machine. Client applications do not require a local transaction server. The remote TransactionCurrent implementation that CORBA clients use, or the remote implementation of UserTransaction that EJB or RMI clients use, delegate the actual responsibility of transaction coordination to transaction manager on the server.

Transaction Propagation (CORBA Only)

For CORBA applications, the CORBAservices Object Transaction Service specification states that a client can choose to propagate a transaction context either implicitly or explicitly. WLE provides implicit propagation. Explicit propagation is strongly discouraged.

Note: For EJB and RMI applications, only implicit propagation is supported for clients.

Objects that are related to transaction contexts that are passed around using explicit transaction propagation should not be mixed with implicit transaction propagation APIs. It should be noted, however, that explicit propagation does not place any constraints on when transactional methods can be processed. There is no guarantee that all transactional methods will be completed before the transaction is committed.

Transaction Integrity

Checked transaction behavior provides transaction integrity by guaranteeing that a commit will not succeed unless all transactional objects involved in the transaction have completed the processing of their transactional requests. If implicit transaction propagation is used, the Transaction Service provides checked transaction behavior that is equivalent to that provided by the request/response interprocess communication models defined by The Open Group. For CORBA applications, for example, the Transaction Service performs reply checks, commit checks, and resume checks, as described in the CORBAservices Object Transaction Service Specification.

Unchecked transaction behavior relies completely on the application to provide transaction integrity. If explicit propagation is used, the Transaction Service does not provide checked transaction behavior and transaction integrity is not guaranteed.

Transaction Termination

WLE allows transactions to be terminated only by the client that created the transaction.

Note: The client may be a server object that requests the services of another object.

Flat Transactions

WLE implements the flat transaction model. Nested transactions are not supported.

Interoperability Between Remote Clients and the WLE Domain

WLE supports remote clients invoking methods on server objects in different WLE domains in the same transaction.

Remote clients with multiple connections to the same WLE domain may make invocations to server objects on these separate connections within the same transaction.

Intradomain and Interdomain Interoperability

For C++ (but not Java) applications, WLE supports native clients invoking methods on server objects in the WLE domain. In addition, WLE supports server objects invoking methods on other objects in the same or in different processes within the same WLE domain.

Network Interoperability

A client application can have only one active bootstrap object and TransactionCurrent object within a single domain. WLE does not support exporting or importing transactions to or from remote WLE domains.

However, transactions can encompass multiple domains in a serial fashion. For example, a server with a transaction active in Domain A can communicate with a server in Domain B within the context of that same transaction.

Relationship of the Transaction Service to Transaction Processing

The Transaction Service relates to various transaction processing servers, interfaces, protocols, and standards in the following ways:

Process Failure

The Transaction Service monitors the participants in a transaction for failures and inactivity. The BEA TUXEDO system provides management tools for keeping the application running when failures occur. Because WLE is built upon the existing BEA TUXEDO transaction management system, it inherits the TUXEDO capabilities for keeping applications running.

Multithreaded Transaction Client Support

WLE supports multithreaded clients for non-transactional clients. For transactional clients, WLE supports only single-threaded client implementation. Clients cannot make transaction requests concurrently in multiple threads.

General Constraints

The following constraints apply to the Transaction Service:

Transaction Service in CORBA Applications

This topic includes the following sections:

These sections describe how WLE implements the OTS, with particular emphasis on the portion of the CORBAservices Object Transaction Service that is described as implementation-specific. They describe the OTS application programming interface (API) that you use to begin or terminate transactions, suspend or resume transactions, and get information about transactions.

Getting Initial References to the TransactionCurrent Object

To access the Transaction Service API and the extension to the Transaction Service API as described later in this chapter, an application needs to complete the following operations:

  1. Create a Bootstrap object. For more information about creating a Bootstrap object, see "C++ Bootstrap Object Programming Reference" in the CORBA C++ Programming Reference.

  2. Invoke the resolve_initial_reference("TransactionCurrent") method on the Bootstrap object. The invocation returns a standard CORBA object pointer. For a description of this Bootstrap object method, see the CORBA C++ Programming Reference.

  3. If an application requires only the Transaction Service APIs, it should issue an org.omg.CosTransactions.Current.narrow() (in Java) or CosTransactions::Current::_narrow() (in C++) on the object pointer returned from step 2 above.

    If an application requires the Transaction Service APIs with the extensions, it should issue a com.beasys.Tobj.TransactionCurrent.narrow() (in Java) or Tobj::TransactionCurrent::_narrow() (in C++) on the object pointer returned from step 2 above.

CORBA Transaction Service API

This topic includes the following sections:

These sections describe the CORBA-based components of the CosTransactions modules that WLE implements to support the Transaction Service. For more information about these components, see Chapter 10 of the CORBAservices: Common Object Services Specification.

Data Types

Listing 2-1 shows the supported data types.

Listing 2-1 Data Types Supported by the Transaction Service


enum Status {

StatusActive,
StatusMarkedRollback,
StatusPrepared,
StatusCommitted,
StatusRolledBack,
StatusUnknown,
StatusNoTransaction,
StatusPreparing,
StatusCommitting,
StatusRollingBack
};

// This information comes from CORBAservices: Common Object
// Services Specification, p. 10-15. Revised Edition:
// March 31, 1995. Updated: March 1997. Used with permission by OMG.


Exceptions

Listing 2-2 shows the supported exceptions in IDL code.

Listing 2-2 Exceptions Supported by the Transaction Service


// Heuristic exceptions
exception HeuristicMixed {};
exception HeuristicHazard {};

// Other transaction-specific exceptions
exception SubtransactionsUnavailable {};
exception NoTransaction {};
exception InvalidControl {};
exception Unavailable {};


Table 2-1 describes the exceptions.

Note: This information comes from CORBAservices: Common Object Services Specification, pages 10-16, 19, 20. Revised Edition: March 31, 1995. Updated: March 1997. Used with permission by OMG.

Table 2-1 Exceptions Supported by the Transaction Service  

Exception

Description

HeuristicMixed

A request raises this exception to report that a heuristic decision was made and that some relevant updates have been committed and others have been rolled back.

HeuristicHazard

A request raises this exception to report that a heuristic decision was made, that the disposition of all relevant updates is not known, and that for those updates whose disposition is known, either all have been committed or all have been rolled back. Therefore, the HeuristicMixed exception takes priority over the HeuristicHazard exception.

SubtransactionsUnavailable

This exception is raised for the Current interface begin method if the client already has an associated transaction.

NoTransaction

This exception is raised for the Current interface rollback and rollback_only methods if there is no transaction associated with the client thread.

InvalidControl

This exception is raised for the Current interface resume method if the parameter is not valid in the current execution environment.

Unavailable

This exception is raised for the Control interface get_terminator and get_coordinator methods if the Control interface cannot provide the requested object.

Current Interface

The Current interface defines methods that allow a client of the Transaction Service to explicitly manage the association between threads and transactions. The Current interface also defines methods that simplify the use of the Transaction Service for most applications. These methods can be used to begin and end transactions, to suspend and resume transactions, and to obtain information about the current transaction.

The CosTransactions module defines the Current interface (shown in Listing 2-3).

Listing 2-3 Current Interface idl


// Current transaction
interface Current : CORBA::Current {
void begin()
raises(SubtransactionsUnavailable);
void commit(in boolean report_heuristics)
raises(
NoTransaction,
HeuristicMixed,
HeuristicHazard
);
void rollback()
raises(NoTransaction);
void rollback_only()
raises(NoTransaction);
Status get_status();
string get_transaction_name();
void set_timeout(in unsigned long seconds);
Control get_control();
Control suspend();
void resume(in Control which)
raises(InvalidControl);

};

// This information comes from CORBAservices: Common Object
// Services Specification, p. 10-18. Revised Edition:
// March 31, 1995. Updated: November 1997. Used with permission by // OMG


Table 2-2 provides a description of the Current transaction methods.

Note: This information comes from CORBAservices: Common Object Services Specification, pages 10-18, 19, 20. Revised Edition: March 31, 1995. Updated: November 1997. Used with permission by OMG.

Table 2-2 Current Transaction Methods  

Method

Description

begin

Creates a new transaction. The transaction context of the client thread is modified so that the thread is associated with the new transaction. If the client thread is currently associated with a transaction, the SubtransactionsUnavailable exception is raised. If the client thread cannot be placed in transaction mode due to an error while starting the transaction, the standard system exception INVALID_TRANSACTION is raised. If the call was made in an improper context, the standard system exception BAD_INV_ORDER is raised.

commit

If there is no transaction associated with the client thread, the NoTransaction exception is raised.

If the call was made in an improper context, the standard system exception BAD_INV_ORDER is raised.

If the system decides to roll back the transaction, the standard exception TRANSACTION_ROLLEDBACK is raised and the thread's transaction context is set to null .

A HeuristicMixed exception is raised to report that a heuristic decision was made and that some relevant updates have been committed and others have been rolled back. A HeuristicHazard exception is raised to report that a heuristic decision was made, and that the disposition of all relevant updates is not known; for those updates whose disposition is known, either all have been committed or all have been rolled back. The HeuristicMixed exception takes priority over the HeuristicHazard exception. If a heuristic exception is raised or the operation completes normally, the thread's transaction exception context is set to null .

If the operation completes normally, the thread's transaction context is set to null .

rollback

If there is no transaction associated with the client thread, the NoTransaction exception is raised.

If the call was made in an improper context, the standard system exception BAD_INV_ORDER is raised.

If the operation completes normally, the thread's transaction context is set to null .

rollback_only

If there is no transaction associated with the client thread, the NoTransaction exception is raised. Otherwise, the transaction associated with the client thread is modified so that the only possible outcome is to roll back the transaction.

get_status

If there is no transaction associated with the client thread, the StatusNoTransaction value is returned. Otherwise, this method returns the status of the transaction associated with the client thread.

get_transaction_name

If there is no transaction associated with the client thread, an empty string is returned. Otherwise, this method returns a printable string describing the transaction (specifically, the XID as specified by The Open Group). The returned string is intended to support debugging.

set_timeout

This method modifies a state variable associated with the target object that affects the time-out period associated with transactions created by subsequent invocations of the begin method.

The initial transaction timeout value is 300 seconds. Calling set_timeout() with an argument value larger than zero specifies a new timeout value. Calling set_timeout() with a zero argument sets the timeout value back to the default of 300 seconds.

After calling set_timeout() , transactions created by subsequent invocations of begin are subject to being rolled back if they do not complete before the specified number of seconds after their creation.

Note: The initial transaction timeout value is 300 seconds. If a transaction is started via AUTOTRAN instead of the begin method, then the timeout value is determined by the TRANTIME value in the WLE configuration file. For more information, see Administering Transactions.

get_control

If the client is not associated with a transaction, a null object reference is returned. Otherwise, a Control object is returned that represents the transaction context currently associated with the client thread. This object may be given to the resume method to reestablish this context.

suspend

If the client thread is not associated with a transaction, a null object reference is returned.

If the associated transaction is in a state such that the only possible outcome of the transaction is to be rolled back, the standard system exception TRANSACTION_ROLLEDBACK is raised and the client thread becomes associated with no transaction.

If the call was made in an improper context, the standard system exception BAD_INV_ORDER is raised. The caller's state with respect to the transaction is not changed.

Otherwise, an object is returned that represents the transaction context currently associated with the client thread. The same client can subsequently give this object to the resume method to reestablish this context. In addition, the client thread becomes associated with no transaction.

Note: As defined in The Common Object Request Broker: Architecture and Specification, Revision 2.2, February 1998, the standard system exception TRANSACTION_ROLLEDBACK indicates that the transaction associated with the request has already been rolled back or has been marked to roll back. Thus, the requested method either could not be performed or was not performed because further computation on behalf of the transaction would be fruitless.

resume

If the client thread is already associated with a transaction which is in a state such that the only possible outcome of the transaction is to be rolled back, the standard system exception TRANSACTION_ROLLEDBACK is raised and the client thread becomes associated with no transaction.

If the call was made in an improper context, the standard system exception BAD_INV_ORDER is raised.

If the system is unable to resume the global transaction because the caller is currently participating in work outside any global transaction with one or more Resource Managers, the standard system exception INVALID_TRANSACTION is raised.

If the parameter is a null object reference, the client thread becomes associated with no transaction. If the parameter is valid in the current execution environment, the client thread becomes associated with that transaction (in place of any previous transaction). Otherwise, the InvalidControl exception is raised.

Note: See suspend for a definition of the standard system exception TRANSACTION_ROLLEDBACK .

Control Interface

The Control interface allows a program to explicitly manage or propagate a transaction context. An object that supports the Control interface is implicitly associated with one specific transaction.

Listing 2-4 shows the Control interface, which is defined in the CosTransactions module.

Listing 2-4 Control Interface


interface Control {
Terminator get_terminator()
raises(Unavailable);
Coordinator get_coordinator()
raises(Unavailable);
};

// This information comes from CORBAservices: Common Object
// Services Specification, p. 10-21. Revised Edition:
// March 31, 1995. Updated: November 1997. Used with permission by // OMG.


The Control interface is used only in conjunction with the suspend and resume methods.

TransactionalObject Interface

The org.omg.CosTransactions.TransactionalObject interface (in Java) or CosTransactions::TransactionalObject (in C++) is used by an object to indicate that it is transactional. By supporting this interface, an object indicates that it wants the transaction context associated with the client thread to be propagated on requests to the object. However, this interface is no longer needed. For details on transaction policies that need to be set to infect objects with transactions, see "Server Description File" in the CORBA Java Programming Reference or "Implementation Configuration File (ICF)" in the CORBA C++ Programming Reference.

The CosTransactions module defines the TransactionalObject interface (shown in Listing 2-5). The org.omg.CosTransactions.TransactionalObject interface defines no methods. It is simply a marker.

Listing 2-5 TransactionalObject Interface


interface TransactionalObject {
};

// This information comes from CORBAservices: Common Object
// Services Specification, p. 10-30. Revised Edition:
// March 31, 1995. Updated: November 1997. Used with permission by // OMG.


Other CORBAservices Object Transaction Service Interfaces

All other CORBAservices Object Transaction Service interfaces are not supported. Note that the Current interface described earlier is supported only if it has been obtained from the Bootstrap object. The Control interface described earlier is supported only if it has been obtained using the get_control and the suspend methods on the Current object.

CORBA Transaction Service API Extensions

This topic describes specific extensions to the CORBAservices Transaction Service API described earlier. The APIs in this topic enable an application to open or close an Open Group Resource Manager.

The following APIs help facilitate participation of Resource Managers in a distributed transaction by allowing their two-phase commit protocol to be controlled via The Open Group XA interface.

The following definitions and interfaces are defined in the com.beasys.Tobj module (in Java) or Tobj module (in C++).

Exception

The following exception is supported:

exception RMfailed {};

A request raises this exception to report that an attempt to open or close a Resource Manager failed.

TransactionCurrent Interface

This interface supports all the methods of the Current interface in the CosTransactions module and is described in "Java Bootstrap Object Programming Reference" in the CORBA Java Programming Reference or in "C++ Bootstrap Object Programming Reference" in the CORBA C++ Programming Reference. Additionally, this interface supports APIs to open and close the Resource Manager.

Listing 2-6 shows the TransactionCurrent interface, which is defined in the Tobj module.

Listing 2-6 TransactionCurrent Interface


Interface TransactionCurrent: CosTransactions::Current {
void open_xa_rm()
raises(RMfailed);
void close_xa_rm()
raises(Rmfailed);
}


Table 2-3 describes APIs that are specific to the Resource Manager. For more information about these APIs, see the CORBA Java Programming Reference or the CORBA C++ Programming Reference.

Table 2-3 Resource Manager APIs for the Current Interface

Method

Description

open_xa_rm

This method opens The Open Group Resource Manager to which this process is linked. A RMfailed exception is raised if there is a failure while opening the Resource Manager.

Any attempts to invoke this method by remote clients or the native clients raises the standard system exception NO_IMPLEMENT .

close_xa_rm

This method closes The Open Group Resource Manager to which this process is linked. An RMfailed exception is raised if there is a failure while closing the Resource Manager. A BAD_INV_ORDER standard system exception is raised if the function was called in an improper context (for example, the caller is in transaction mode).

Any attempts by the remote clients or the native clients to invoke this method raises the standard system exception NO_IMPLEMENT .

Notes on Using Transactions in WLE CORBA Applications

Consider the following guidelines when integrating transactions into your WLE CORBA client/server applications:

Transaction Service in EJB Applications

The WLE EJB Container provides a Transaction Service that supports the two types of transactions in WLE EJB applications:

For an introduction to transaction management in EJB applications, see Transactions in WLE EJB Applications, and Transactions Sample EJB Code.

Transaction Service in RMI Applications

WLE provides a Transaction Service that supports transactions in WLE RMI applications. In RMI applications, the client or server application makes explicit method invocations on the UserTransaction object to begin, commit, and roll back transactions.

For more information about UserTransaction methods, see UserTransaction API. For an introduction to transaction management in RMI applications, see Transactions in WLE RMI Applications, and Transactions Sample RMI Code.

UserTransaction API

This topic includes the following sections:

WLE provides Sun Microsystems, Inc.'s javax.transaction package, which implements the Java Transaction API (JTA) for Java applications. The javax.UserTransaction interface supports transaction management for CORBA Java applications as well as for bean-managed transactions in EJB applications. For more information about the JTA, see Sun Microsystem's Java Transaction API (JTA) Specification (version1.0.1). For a detailed description of the javax.transaction interface, see the package description in the WLE Javadoc.

UserTransaction Methods

Table 2-4 describes the methods in the UserTransaction object.

Table 2-4 UserTransaction Methods  

Method Name

Description

begin

Starts a transaction on the current thread.

commit

Commits the transaction associated with the current thread.

getStatus

Returns the transaction status, or STATUS_NO_TRANSACTION if no transaction is associated with the current thread.

One of the following values:

rollback

Rolls back the transaction associated with the current thread.

setRollbackOnly

Marks the transaction associated with the current thread so that the only possible outcome of the transaction is to roll it back.

setTransactionTimeout

Specifies the timeout value for the transactions started by the current thread with the begin method. If an application has not called the begin method, then the Transaction Service uses a default value for the transaction timeout.

Exceptions Thrown by UserTransaction Methods

Table 2-5 describes exceptions thrown by methods of the UserTransaction object.

Table 2-5 Exceptions Thrown by UserTransaction Methods  

Exception

Description

HeuristicMixedException

Thrown to indicate that a heuristic decision was made and that some relevant updates have been committed while others have been rolled back.

HeuristicRollbackException

Thrown to indicate that a heuristic decision was made and that some relevant updates have been rolled back.

NotSupportedException

Thrown when the requested operation is not supported (such as a nested transaction).

RollbackException

Thrown when the transaction has been marked for rollback only or the transaction has been rolled back instead of committed.

IllegalStateException

Thrown if the current thread is not associated with a transaction.

SecurityException

Thrown to indicate that the thread is not allowed to commit the transaction.

SystemException

Thrown by the Transaction Manager to indicate that it has encountered an unexpected error condition that prevents future transaction services from proceeding.