Programming Guide



xa_rollback

Aborts an XA-compliant transaction

Synopsis

xa_rollback

Environment

Oracle Tuxedo

Scope

Client, Server

Description

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:

On return, xa_rollback sets the tp_return property to one of these values:

Example

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_msg
receive 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"})
}
...

Exceptions

The xa_rollback command can generate the following exceptions:

Exception Severity Cause
TP_MONITOR_ERROR
TP_ERROR

An error is reported from the middleware

TP_ROLLBACK_COMMITTED
TP_ERROR

Transaction cannot be rolled back because it has already been committed

TP_ROLLBACK_FAILED
TP_ERROR

Transaction could not be rolled back

TP_INVALID_TRANSACTION
TP_COMMAND

There is no current transaction

See Also

xa_begin, xa_commit, xa_end