Begin Transaction Service
The Begin Transaction service marks the start of a multi-step transaction in a business process. All of the steps after this service are part of one transaction and are committed or rolled back at the same time.
The following table provides an overview of the Begin Transaction service.
System name | Begin Transaction Service |
---|---|
Graphical Process Modeler (GPM) categories | All Services |
Description | Starts a transaction. |
Business usage | Use this service to mark the start of a multi-step transaction in a business process. All of the steps after this service are part of one transaction and are committed or rolled back at the same time. This service should be used with the End Transaction service. The Begin Transaction service can also be used for global transactions where the transaction spans across adapters such as the MQ and Lightweight JDBC adapters. |
Usage example | Consider a customer ordering items online and using a shopping cart. The
merchant's business process:
|
Preconfigured? | Yes |
Requires third party files? | No |
Platform availability | All supported Sterling B2B Integrator platforms |
Related services | The Begin Transaction service should be used with the End Transaction service. |
Application requirements | Nothing external is required to use this service. |
Initiates business processes? | No |
Invocation | This service is invoked from a business process. |
Business process context considerations | No |
Returned status values | Returned status values:
|
Restrictions | N/A |
Testing considerations | N/A |
How the Begin Transaction Service Works
Use the Begin Transaction service to start a multi-step transaction.
Business Process Example
- Gets a document containing shopping cart information (customer information, product details).
- Inserts the customer information to the customer database table.
- Inserts product details to the invoice database table (product_id, quantity purchased)
- Updates the quantity of the product from the inventory database table as the products are sold.
For example, if step 4 fails (update the quantity), but steps 1 and step 2 were committed. The merchant's inventory database table is now inaccurate, because the items were reported as sold, but the items were not deducted from the inventory database table. The Begin Transaction service and End transaction service make it possible to have a transaction where all the steps are committed successfully or all the steps are rolled back.
<process name="TestTran">
<sequence>
<operation name="Begin">
<participant name="BeginTransactionService"/>
<output message="Xout">
<assign to="START_TRANSACTION">TRUE</assign>
<assign to="DISTRIBUTED">TRUE</assign>
</output>
<input message="Xin">
<assign to="." from="*"></assign>
</input>
</operation>
<operation name="XML Encoder">
<participant name="XMLEncoder"/>
<output message="XMLEncoderTypeInputMessage">
<assign to="output_to_process_data">YES</assign>
<assign to="root_element">root</assign>
<assign to="mode">xml_to_process_data</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
<operation name="LightweightJDBCAdapterType">
<participant name="LightweightJDBCAdapterQuery"/>
<output message="LightweightJDBCAdapterTypeInputMessage">
<assign to="schedHour">-1</assign>
<assign to="result_name">result</assign>
<assign to="schedDay">-2</assign>
<assign to="sql">INSERT INTO CUSTOMER_LW (CUSTOMER_ID,
SIR_NAME, FIRST_NAME, MIDDLE_INITIAL, LAST_NAME, ADDRESS, CITY,
STATE, ZIP, PHONE_NUM, EMAIL, ORDERS_PLACED, EMPLOYER,
WORK_PHONE, WORK_EMAIL WORK_ADDRESS1, WORK_ADDRESS2, WORK_CITY,
WORK_STATE, WORK_ZIP) VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
</assign>
<assign to="param1" from="Testplan/Test4/Customer_ID/text()"></assign>
<assign to="paramtype1">Integer</assign>
<assign to="param2" from="Testplan/Test4/SirName/text()"></assign>
<assign to="paramtype2">String</assign>
<assign to="param3" from="Testplan/Test4/FirstName/text()"></assign>
<assign to="paramtype3">String</assign>
<assign to="param4" from="Testplan/Test4/MiddleInitial/text()"></assign>
<assign to="paramtype4">String</assign>
<assign to="param5" from="Testplan/Test4/LastName/text()"></assign>
<assign to="paramtype5">String</assign>
<assign to="param6" from="Testplan/Test4/Address/text()"></assign>
<assign to="paramtype6">String</assign>
<assign to="param7" from="Testplan/Test4/City/text()"></assign>
<assign to="paramtype7">String</assign>
<assign to="param8" from="Testplan/Test4/State/text()"></assign>
<assign to="paramtype8">String</assign>
<assign to="param9" from="Testplan/Test4/Zip/text()"></assign>
<assign to="paramtype9">String</assign>
<assign to="param10" from="Testplan/Test4/Phone_Num/text()"></assign>
<assign to="paramtype10">String</assign>
<assign to="param11" from="Testplan/Test4/Email/text()"></assign>
<assign to="paramtype11">String</assign>
<assign to="param12" from="Testplan/Test4/Orders_Placed/text()"></assign>
<assign to="paramtype12">Integer</assign>
<assign to="param13" from="Testplan/Test4/Employer/text()"></assign>
<assign to="paramtype13">String</assign>
<assign to="param14" from="Testplan/Test4/Work_Phone/text()"></assign>
<assign to="paramtype14">String</assign>
<assign to="param15" from="Testplan/Test4/Work_Email/text()"></assign>
<assign to="paramtype15">String</assign>
<assign to="param16" from="Testplan/Test4/Work_Address1/text()"></assign>
<assign to="paramtype16">String</assign>
<assign to="param17" from="Testplan/Test4/Work_Address2/text()"></assign>
<assign to="paramtype17">String</assign>
<assign to="param18" from="Testplan/Test4/Work_City/text()"></assign>
<assign to="paramtype18">String</assign>
<assign to="param19" from="Testplan/Test4/Work_State/text()"></assign>
<assign to="paramtype19">String</assign>
<assign to="param20" from="Testplan/Test4/Work_Zipcode/text()"></assign>
<assign to="paramtype20">String</assign>
<assign to="pool">mysqlPool</assign>
<assign to="row_name">row</assign>
<assign to="schedMinute">-1</assign>
<assign to="query_type">ACTION</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
<operation name="LightweightJDBCAdapterType">
<participant name="LightweightJDBCAdapterQuery"/>
<output message="LightweightJDBCAdapterTypeInputMessage">
<assign to="schedHour">-1</assign>
<assign to="result_name">result</assign>
<assign to="schedDay">-2</assign>
<assign to="sql">INSERT INTO INVOICE CUSTOMER_ID,PRODUCT_ID,QTY)
VALUES (?, ?, ?) </assign>
<assign to="param1" from="Testplan/Test4/Customer_ID/text()"></assign>
<assign to="paramtype1">Integer</assign>
<assign to="param2" from="Testplan/Test4/PRODUCT_ID/text()"></assign>
<assign to="paramtype2">String</assign>
<assign to="param3" from="Testplan/Test4/QUANTITY/text()"></assign>
<assign to="paramtype3">Integer</assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
<operation name="LightweightJDBCAdapterType">
<participant name="LightweightJDBCAdapterQuery"/>
<output message="LightweightJDBCAdapterTypeInputMessage">
<assign to="schedHour">-1</assign>
<assign to="result_name">result</assign>
<assign to="schedDay">-2</assign>
<assign to="sql">INSERT INTO PRODUCT QTY VALUES (?) WHERE PRODUCT_ID=?
</assign>
<assign to="param1" from="Testplan/Test4/QUANTITY/text()"></assign>
<assign to="paramtype2">Integer</assign>
<assign to="param3" from="Testplan/Test4/PRODUCT_ID/Text()"></assign>
<assign to="paramtype3">String</assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
<operation>
<participant name="EndTransactionService"/>
<output message="Xout">
<assign to="END_TRANSACTION">TRUE</assign>
</output>
<input message="Xin">
<assign to="." from="*"></assign>
</input>
</operation>
</sequence>
</process>
Implementing the Begin Transaction Service
- Use the Begin Transaction service in a business process.
- Use the End Transaction service to end the transaction.Note: When a pool is defined in
jdbc.properties
, you must mark the pool being referenced as transactional:myPool.transactional=true
Output from Business Process to Service
The following table contains the parameter passed from the business process to the Begin Transaction service:
Parameter | Description |
---|---|
Start Transaction | Starts the transaction. Must be set to TRUE for processing to be transactional. Valid value is true (default) or false. Required. |
Distributed | Controls whether or not the transaction is distributed or extended to adapters with transactional support. For additional information, see Listing of Services and Adapters by type for a list of adapters with transactional support. Valid value is true or false (default). Optional. |
On Fault | Controls the action to take when an error occurs. To undo the transaction to the point of error, select ROLLBACK. To keep the work done to the point of error to occur, select COMMIT. Valid value is Rollback or Commit (default). Optional. |