OpenTP1 Version 7 Programming Guide

[Contents][Index][Back][Next]

5.2.2 How to use TX_ functions

Organization of this subsection
(1) Starting a transaction
(2) Obtaining synchronization point
(3) Setting transaction characteristics
(4) Obtaining transaction information
(5) Relation to user service definition

(1) Starting a transaction

To start a transaction by TX_ functions, call the functions from UAP as shown below. To call the functions in this order, the transaction can be started regardless of the atomic_update specification in the user service definition. If atomic_update = Y is specified in the user service definition, transaction processing start can be called unless tx_open() [TXOPEN] and tx_close() [TXCLOSE] are called.

Starting a transaction by SUP
dc_rpc_open()
tx_open()
tx_begin()
      :
      :
tx_commit() (synchronization point processing)
tx_close()
      :   tx_open( ) and tx_close( ) can be reissued in this section.
dc_rpc_close()

Starting a transaction by SPP (starting by service functions)
dc_rpc_open()
tx_open()
dc_rpc_mainloop()
      :
(Service function processing)
tx_begin()
      :
      :
tx_commit() (synchronization point processing)
      :
(Main function dc_rpc_mainloop() returns.)
tx_close()
      :
dc_rpc_close()

When starting a transaction within the service functions of SPP, call tx_open() before the function dc_rpc_mainloop().

(2) Obtaining synchronization point

Transaction processing started by tx_begin() [TXBEGIN] must always be completed by the function that obtains synchronization point (tx_commit() [TXCOMMIT] or tx_rollback() [TXROLLBACK]).

The chained mode (TX_CHAINED) and unchained mode (TX_UNCHAINED) are provided for tx_commit() and tx_rollback(). When starting a new global transaction after obtaining synchronization point, set the chained mode. When terminating transaction processing without starting a new transaction, set the unchained mode. The chained or unchained mode is set as a transaction_control characteristic by tx_set_transaction_control() [TXSETTRANCTL].

(3) Setting transaction characteristics

Characteristics of transaction processing can be set by TX_ functions.

(a) commit_return characteristic

When a transaction is committed in two phases, you can set whether control returns upon completion of the first or second phase. With the corresponding version of OpenTP1, return before completion of the second phase cannot be set. If such return is set, control returns with error. commit_return characteristic is set by tx_set_commit_return() [TXSETCOMMITRET].

(b) transaction_control characteristic

Sets whether a new transaction is to be started (chained mode or unchained mode) after the synchronization point (tx_commit() or tx_rollback()). For transaction_control characteristic, set either TX_CHAINED or TX_UNCHAINED by tx_set_transaction_control() [TXSETTRANCTL].

(c) transaction_timeout characteristic

Monitoring time for transactions can be set. The transaction_timeout characteristic is set by tx_set_transaction_timeout() [TXSETTIMEOUT]. The transaction_timeout characteristic set by tx_set_transaction_timeout() has priority over the value of trn_expiration_time defined by the system.

(4) Obtaining transaction information

tx_info() [TXINFORM] enables the structures containing transaction branch IDs or transaction characteristics to be referenced.

The following shows the formats of the structures that can be referenced.

XID                    xid;
COMMIT_RETURN          when_return;
TRANSACTION_CONTROL    transaction_control;
TRANSACTION_TIMEOUT    transaction_timeout;
TRANSACTION_STATE      transaction_state;

(5) Relation to user service definition

By using tx_open() and tx_close(), processing after tx_begin() can be processed as a transaction, regardless of the value of atomic_update in the user service definition.

When a service is called by the UAP which called tx_begin(), processing of the service is included in the global transaction, regardless of the specification of atomic_update in the server UAP.