Managing explicit OTS transactions

You can code components (and clients) to initiate and complete transactions using the OTS (Object Transaction Service) CosTransactions::Current or CosTransactions::TransactionFactory interfaces.

NoteIn order to use OTS, you must enable EAServer to use the OTS/XA transaction coordinator. See Chapter 3, “Creating and Configuring Servers,” in the EAServer System Administration Guide for more information.

To use the functionality of these interfaces, include CosTransactions.hpp in your source file.

To explicitly use transactions in a component or client, use the CosTransactions::Current interface to perform these tasks.

Task

Call this method

Catch these exceptions

Start a transaction.

begin

SubtransactionsUnavailable

Temporarily stop a transaction.

suspend

None

Resume a suspended transaction.

resume

InvalidControl

Commit a transaction.

commit

NoTransaction, HeuristicMixed, HeuristicHazard

Roll back a transaction.

rollback

NoTransaction

Make the only possible outcome of the transaction a rollback.

rollback_only

NoTransaction

Roll back a transaction after a specified amount of time has elapsed without any response.

set_timeout

None

Retrieve a transaction’s status.

get_status

None

Retrieve a transaction’s name. Use this method when you need to debug transactions.

get_transaction_name

None

Using factories

The TransactionFactory interface is included in EAServer only to maintain compatibility with the CORBA OTS specification—Sybase recommends that you use the CosTransactions::Current interface to create explicit transactions.

NoteSybase recommends that you use suspend with caution so as not to conflict with the EAServer component model. For example, do not use suspend to take control of a transaction that it does not control.