webMethods Adapter Runtime 10.3 | webMethods Adapter Runtime Documentation | Adapters RunTime Users Documentation | Transaction Management | Explicit Transactions | Explicit Transaction Usage Cases | Two Local Transactions
 
Two Local Transactions
To make this flow work properly, explicitly start and commit the nested local transaction, using the startTransaction and commitTransaction services as follows:
BEGIN FLOW // start transaction 1
INVOKE interactWithResourceA // service for transaction 1

INVOKE startTransaction(2) // start transaction 2
INVOKE interactWithResourceB // service for transaction 2
INVOKE commitTransaction(2) // commit transaction 2

END FLOW // commit transaction 1
The flow executes as follows:
1. When interactWithResourceA is invoked, Integration Server starts transaction 1 and enlists ResourceA.
2. Transaction 2 executes as follows:
a. When startTransaction(2) is invoked, Integration Server starts a new, nested transaction.
b. When interactWithResourceB is invoked, ResourceB is enlisted in transaction 2.
c. When commitTransaction(2) is invoked, the connection to ResourceB is closed, and transaction 2 is committed. At this point, only the work done on ResourceB is committed; transaction 1 is still open, and the work done with ResourceA is not yet committed.
3. When the flow ends, Integration Server closes the connection for transaction 1 and commits its work to ResourceA.
Note:
Each transaction is a separate unit of work. Transaction 1 could be rolled back (or the commit could fail), while transaction 2 remains committed (or vice versa).
Alternatively, to achieve the same result, you can explicitly start transaction 1 before the adapter service is invoked, and explicitly commit it as follows:
BEGIN FLOW
INVOKE startTransaction(1) // start transaction 1
INVOKE interactWithResourceA // service for transaction 1
INVOKE startTransaction(2) // start transaction 2
INVOKE interactWithResourceB // service for transaction 2
INVOKE commitTransaction(2) // commit transaction 2
INVOKE commitTransaction(1) // commit transaction 1
END FLOW