Programming Guide |
Aborts an XA-compliant transaction
xa_rollback
Oracle Tuxedo
Client, Server
The
xa_rollback
command aborts the current middleware transaction. If a transaction has unfinished work, this command cancels all outstanding requests and rolls back all child transactions. Unfinished work includes:
- A service request performed as part of the transaction that has not yet completed.
- Resource manager data manipulation that is not yet committed.
On return,
xa_rollback
sets thetp_return
property to one of these values:
TP_PARTIAL_COMMIT
—The transaction is partially committed.
TP_NOT_COMPLETED
—The attempt to rollback failed; the transaction remains viable.
In the following example, service transfer is called by a client to transfer money between accounts. transfer first calls service withdrawal to withdraw the amount from the debit account. If this fails, the entire transaction is rolled back.
// Client code:
...
service_call "transfer" \
({debit_acct_id, credit_acct_id, amount },\
{message, debit_bal, credit_bal})
if (@app()->tp_svc_outcome ! = TP_SUCCESS
{
msg emsg message
}
...// Service: transfer
proc transfer
vars withdrawal_msgreceive arguments \
({debit_acct_id, credit_acct_id, amount})
xa_begin
service_call "withdrawal" \
({account_id = debit_acct_id, amount}, \
{message=withdrawal_msg, balance = debit_bal})
if ((@app()->tp_severity > TP_WARNING) ||
(@app()->tp_svc_outcome !=TP_SUCCESS))
{
xa_rollback
service_return FAILURE \
({message = "Debit account problem -- :withdrawal_msg"})
}
...
The
xa_rollback
command can generate the following exceptions: