Adapter for JDBC 10.3 | webMethods Adapter for JDBC Documentation | webMethods Adapter for JDBC Installation and User’s Documentation | Built-In Transaction Management Services | Transaction Management Overview | Implicit and Explicit Transaction Examples
 
Implicit and Explicit Transaction Examples
The examples in this section use the connections, services, and flows shown below and described in the table that follows.
Step
Description
1
You configured three connections:
*localConn1: LOCAL_TRANSACTION type
*localConn2: LOCAL_TRANSACTION type
*xaConn1: XA_TRANSACTION type
2
You configured the following adapter services which use the LOCAL_TRANSACTION connections listed in step 1 above.
*InsertLocal1: configured to use localConn1 connection
*SelectLocal1: configured to use localConn1 connection
*SelectLocal2: configured to use localConn2 connection
3
You configured the following adapter services which use the XA_TRANSACTION connection listed in step 1 above.
*InsertXA1: uses xaConn1 connection
*SelectXA1: uses xaConn1 connection
4
You create the following flow examples (described in this section) using LOCAL_TRANSACTIONs:
*SingleLocalInsert (explicit transaction). See Flow Example: SingleLocalInsert.
*ValidDoubleLocal (explicit transaction). See Flow Example: ValidDoubleLocal.
5
You create the following flow examples (described in this section) using both XA_TRANSACTIONs and LOCAL_TRANSACTIONs:
*ValidMixed (implicit transaction). See Flow Example: ValidMixed.
*ValidMixed2 (implicit/explicit transaction). See Flow Example: ValidMixed2.
Flow Example: ValidMixed
*This examples shows an Implicit Transaction.
*This flow calls:
*One service using an XA_TRANSACTION connection (InsertXA1 service)
*One service using a LOCAL_TRANSACTION connection (SelectLocal2 service)
Flow Example: SingleLocalInsert
*This examples shows an Explicit Transaction.
*This flow calls one adapter service (InsertLocal1) using a LOCAL_TRANSACTION connection.
This example demonstrates the correct way to set up your flow to use an explicit transaction. You use the following construct of three SEQUENCEs, which is required to insure that the explicit transaction is either committed (on success) or rolled back (on failure).
Step
Description
1
The top-level SEQUENCE will exit on success. Note that the start transaction is outside the SEQUENCE.
2
The transaction will be committed if successful, and the top-level SEQUENCE will complete.
3
This SEQUENCE is entered only if the previous SEQUENCE is unsuccessful. The transaction is rolled back and the flow exits with a status of failure.
Note that with this construct, you will not get trigger retries or a retryable exception. The EXIT statement will result in generating a Flow exception which is not retryable. To get retries, you will need to use a REPEAT step statement in your flow. For information about using the REPEAT statement, see the webMethods Service Development Help for your release.
Flow Example: ValidMixed2
*This examples shows both an Implicit and Explicit Transaction.
*This flow calls:
*One adapter service (InsertXA1) using an XA_TRANSACTION connection
*One flow (SingleLocalInsert-shown in Flow Example: SingleLocalInsert) which contains its own explicit transactions and using a LOCAL_TRANSACTION connection (localConn1)
*One adapter service (SelectLocal2) using the same LOCAL_TRANSACTION connection (localConn2) as the SingleLocalInsert flow
In this example, InsertXA1 and SelectLocal2 are registered as part of the implicit transaction. SingleLocalInsert is part of its own explicit transaction. The explicit transaction is required since you are using two different local transaction connections (localConn1 and localConn2).
Flow Example: ValidDoubleLocal
*This example shows an Explicit transaction.
*This flow calls:
*A flow (SingleLocalInsert) which uses the LOCAL_TRANSACTION connection localConn1
*An adapter service (SelectLocal2) which uses the LOCAL_TRANSACTION connection localConn2
This flow shows an explicit transaction residing within another explicit transaction. The flow calls a flow and an adapter service which use different LOCAL_TRANSACTION connections. Recall that you must use an explicit transaction if you have more than one LOCAL_TRANSACTION connection.
Notice that the flow is similar to the SingleLocalInsert flow example shown in Flow Example: SingleLocalInsert, which uses a flow construct involving three SEQUENCEs to insure that the explicit transaction is either committed (on success) or rolled back (on failure).
Step
Description
1
The top-level SEQUENCE will exit on success. Note that the start transaction is outside the SEQUENCE.
2
The transaction will be committed if successful, and the top-level SEQUENCE will complete.
3
This SEQUENCE is entered only if the previous SEQUENCE is unsuccessful. The transaction is rolled back and the flow exits with a status of failure.