Configurable transaction mode
Use the transaction mode to define whether job-related artifacts are called in global transaction mode or local transaction mode. Specify the transaction mode in the xJCL.
The following list describes the options for the com.ibm.websphere.batch.transaction.policy property.
- global
Specifies that all job-related artifacts including listeners, batch data streams, and checkpoint algorithms, are called in global transaction mode. This option is the default.
- local
- Specifies that all job-related artifacts including listeners, batch data streams, and checkpoint algorithms, are called in local transaction mode.
Updates to the local job status table and the database must be done through the same connection to maintain transaction integrity.
Transaction mode xJCL example
Specify a job level property:
<job ..... ... <props> <prop name="com.ibm.websphere.batch.transaction.policy" value="LOCAL"/> </props> ....Because the local transaction mode is specified, all user code must share the JDBC connection with the batch container. The batch container creates and saves a JDBC connection in the job step context. We can fetch the job step context with the following code:
java.sql.Connection conn = JobStepContextMgr.getContext().getSharedSQLConnection();
Do not attempt to create a JDBC connection or close a connection obtained with the job step context. Local transaction support is built into the batch data stream framework JDBC reader or JDBC writer patterns. Setting the com.ibm.websphere.batch.transaction.policy property to local forces the batch data stream framework to use the shared JDBC connection.
Related tasks
Develop a simple transactional batch application