![]() |
![]() |
|
|
Suspending and Resuming a Transaction
At times, it may be desirable to temporarily remove a process from an incomplete transaction and allow it to initiate a different transaction by calling tpbegin() or tpresume(). For example, suppose a server wants to log a request to the database central event log, but does not want the logging activity to be rolled back if the transaction aborts.
The BEA Tuxedo system provides two functions that allow a client or server to suspend and resume a transaction in such situations: tpsuspend(3c) and tpresume(3c). Using these functions, a process can:
Suspending a Transaction
Use the tpsuspend(3c) function to suspend the current transaction. Use the following signature to call the tpsuspend() function.
int
tpsuspend(TPTRANID *t_id,long flags)
The following table describes the arguments to the tpsuspend() function.
tpsuspend( ) Function Arguments
Field |
Description |
---|---|
*t_id |
Pointer to the transaction identifier. |
flags |
Currently not used. Reserved for future use. |
You cannot suspend a transaction with outstanding asynchronous events. When a transaction is suspended, all modifications previously performed are preserved in a pending state until the transaction is committed, aborted, or timed out.
Resuming a Transaction
To resume the current transaction, use the tpresume(3c) function with the following signature.
int
tpresume(TPTRANID *t_id,long flags)
The following table describes the arguments to the tpresume() function.
tpresume( ) Function Arguments
Field |
Description |
---|---|
*t_id |
Pointer to the transaction identifier. |
flags |
Currently not used. Reserved for future use. |
It is possible to resume a transaction from a process other than the one that suspended it, subject to certain restrictions. For a list of these restrictions, refer to tpsuspend(3c) and tpresume(3c) in the BEA Tuxedo C Function Reference.
Example: Suspending and Resuming a Transaction
The following example shows how to suspend one transaction, start and commit a second transaction, and resume the initial transaction. For the sake of simplicity, error checking code has been omitted.
Suspending and Resuming a Transaction
DEBIT(SVCINFO *s)
{
TPTRANID t;
tpsuspend(&t,TPNOFLAGS); /* suspend invoking transaction*/
tpbegin(30,TPNOFLAGS); /* begin separate transaction */
Perform work in the separate transaction.
tpcommit(TPNOFLAGS); /* commit separate transaction */
tpresume(&t,TPNOFLAGS); /* resume invoking transaction*/
.
.
.
tpreturn(. . . );
}
![]() |
![]() |
![]() |
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|