Transaction

The Transaction class provides in interface to the transaction functions of the BEA TUXEDO ATMI.
 

Hierarchy

BEATuxBldr · Transaction
 

Description

Transaction provides member functions that perform all transaction-related operations. By incorporating these operations into Transaction, ATMI transaction error codes are integrated into the exception handling structure of the application. Transaction objects are pseudo-objects, used solely to access the operations in the class. Transaction is very similar to CosTransactions::Current in the BEA TUXEDO Builder Active Expert.

Transaction pseudo-objects are instantiated using this constructor:

void Transaction::begin() throw(NoTransaction*, 
SubtransactionsUnavailable*);

An application should create a Transaction object when it needs to perform transaction demarcation operations. This class is used for transactions the application explicitly originates and for implicit, on-going global transactions that the application participates in.

The TX transaction processing API functions tx_open and tx_close are not represented in this class. They should be implemented in the open_xa_rm and close_xa_rm member functions of Server.
 

Data Types

This section lists the data types of Transaction class

Table 4-27 Transaction Data Types

Data Type Access Documented in

Status

public

Transaction


 

Status


 

Description

Status is an enumerated type that indicates the status of a transaction. Valid values for Status are:

Table 4-28 Generated Service Request Status Modes

Name Description

StatusNoTransaction

When there is no active transaction.

StatusActive

When there is an active transaction.

StatusMarkedRollBack

When there is an active transaction, and it has been marked to be rolled-back.

Use GetInvoke to determine the current value of InvocationType, and SetInvoke to specify a new value.
 

Member Functions

This section lists the member functions of Transaction.

Table 4-29 Transaction Member Functions

Member Function Access Documented in

begin

public

Transaction

commit

public

Transaction

get_status

public

Transaction

resume

public

Transaction

rollback

public

Transaction

rollback_only

public

Transaction

set_timeout

public

Transaction

suspend

public

Transaction

Transaction

public

Transaction


 

begin

begin starts a global transaction on behalf of the caller.
 

Synopsis

void begin() throw(NoTransaction*, SubtransactionsUnavailable*)

 

Throws

SubtransactionsUnavailable*
A SubtransactionsUnavailable exception is thrown if an attempt is made to start a nested transaction. Nested transactions are not supported, as BEA TUXEDO does not currently support them.

 

commit

commit uses the two-phase commit protocol to commit the active transaction.
 

Synopsis

void commit(Boolean reportHeuristics) throw(NoTransaction*, 
HeuristicMixed*, HeuristicException*)

 

Parameters

reportHeuristics
If TRUE, the function returns only after the second phase of two-phase commit protocol has been completed.

If FALSE, the operation returns after the commit decision has been logged, but before the second phase has been completed.

 

Throws

HeuristicHazard*
When the work done on behalf of the transaction has been aborted.

HeuristicMixed*
When the work done on behalf of transaction has been partially aborted and partially committed due to a heuristic decision taken by the database.

NoTransaction*
When there is no active transaction to commit.

 

get_status

get_status returns value of Status, which indicates the status of a transaction.
 

Synopsis

Status get_status()

 

resume

resume is used to resume work on behalf of the active transaction.
 

Synopsis

void resume(Control*) throw (InvalidControl*)

 

Parameters

Control*
Control is the pseudo-object returned by a previous suspend. There is no effect if resume is passed a NULL Control object.

 

Throws

InvalidControl*
A InvalidControl exception is thrown if resume is passed an invalid Control object.

 

Description

The only valid Control object that can be passed to resume is one obtained by a prior call to the suspend function.
 

rollback

rollback aborts the current active transaction.
 

Synopsis

void rollback(void) throw(NoTransaction*)

 

Throws

NoTransaction*
A NoTransaction exception is thrown if there is no active transaction.

Note: This member function is identical to rollback_only.


 

rollback_only

rollback_only aborts the current active transaction.
 

Synopsis

void rollback_only(void) throw (NoTransaction*)

 

Throws

NoTransaction*
A NoTransaction exception is thrown if there is no active transaction.

Note: This member function is identical to rollback.


 

set_timeout

set_timeout sets the time-out period for subsequent transactions.
 

Synopsis

void set_timeout(unsigned long seconds) throw()

 

Description

This function can be invoked to establish the time-out value for the next transaction started with begin.
 

suspend

suspend is used to suspend work on behalf of the active transaction.
 

Synopsis

Control* suspend()

 

Returns

Control*
A pointer to the Control pseudo-object is used by resume to reactivate the transaction.

 

Description

Operations performed after suspend is invoked are not included in the active transaction. Use resume to include further operations in the active transaction.

The suspend member function returns a Control if there is an active transaction. If there is no active transaction, it returns a NULL object reference.
 

Transaction

Instantiates a Transaction pseudo-object.
 

Synopsis

Transaction()

 

Description

A client or server application must have a reference to a Transaction pseudo-object before it can use any of the other member functions of this class.