webMethods Adapter Runtime 10.7 | webMethods Adapter Runtime Documentation | webMethods Adapter Runtime User’s Documentation | Transaction Management | Explicit Transactions | Explicit Transaction Usage Cases | One XAResource Transaction and Two Nested Local Transactions
 
One XAResource Transaction and Two Nested Local Transactions
The following flow includes three transactions: one XAResource transaction that interacts with two resources, and two nested local transactions that interact with one resource each.
BEGIN FLOW // start XAResource transaction 1
INVOKE interactWithXAResourceA // service for XAResource transaction 1
INVOKE interactWithXAResourceB // service for XAResource transaction 2
INVOKE startTransaction(2) // start local transaction 1
INVOKE interactWithLocalResourceA // service for local transaction 1
INVOKE commitTransaction(2) // commit local transaction 1
INVOKE startTransaction(3) // start local transaction 2
INVOKE interactWithLocalResourceB // service for local transaction 2
INVOKE commitTransaction(3) // commit local transaction 2
END FLOW // commit XAResource transaction 1
The flow executes as follows:
1. When interactWithXAResourceA is invoked, Integration Server starts transaction 1 and enlists XAResourceA.
2. When interactWithXAResourceB is invoked, Integration Server enlists XAResourceB in transaction 1.
3. Transaction 2 is executed as follows:
a. When startTransaction(2) is invoked, Integration Server starts a new, nested transaction.
b. When interactWithLocalResourceA is invoked, LocalResourceA is enlisted in transaction 2.
c. When commitTransaction(2) is invoked, the connection to LocalResourceA is closed, and transaction 2 is committed. At this point, only the work done on LocalResourceA is committed; transaction 1 is still open, and the work done with XAResourceA and XAResourceB is not yet committed.
4. Transaction 3 is executed as follows:
a. When startTransaction(3) is invoked, Integration Server starts a new, nested transaction.
b. When interactWithLocalResourceB is invoked, LocalResourceB is enlisted in transaction 3.
c. When commitTransaction(3) is invoked, the connection to LocalResourceB is closed, and transaction 3 is committed. At this point, only the work done on LocalResourceA and LocalResourceB is committed; transaction 1 is still open, and the work done with XAResourceA and XAResourceB is not yet committed.
5. When the flow ends, Integration Server closes the connection for transaction 1 and commits its work to XAResourceA and XAResourceB.