+

Search Tips   |   Advanced Search

Batch job steps

We can separate tasks of a batch application into batch steps. Batch steps are implemented as Plain Old Java Object (POJO) classes that implement the interface, com.ibm.websphere.batch.BatchJobStepInterfance. Batch job steps are performed sequentially.

Callback methods in the BatchJobStepInterface allow the grid endpoints to run batch steps when it runs a batch job.

A batch step contains the batchable business logic to run for a portion of the batch job. Typically, a batch step contains code to read a record from a batch data stream, perform business logic with that record and then continue to read the next record. The processJobStep method of a batch step class is called by the grid endpoints in a batch loop. This method contains all the logic that can be batched to perform on data.

The grid endpoints invoke batch step class methods in a global transaction. This global transaction is managed by the grid endpoints. The behavior of the transaction, such as transaction timeout or transaction commit interval, is controlled by the checkpoint algorithm associated with the batch job to which the step belongs.

The following grid endpoints callback methods exist on the BatchJobStepInterface that are invoked by the grid endpoints:

Callback method Description
setProperties(java.util.Properties properties) Makes properties defined in XML Job Control Language (xJCL) available to batch step in a java.util.Properties object. This method is invoked in a global transaction.
void createJobStep() Indicates to the step that it has been initialized. Initialization logic, such as retrieving a handle to a batch data stream, can be placed here. This method is invoked in a global transaction.
int processJobStep() Repeatedly invoked by grid endpoints in a batch loop until the return code integer of this method indicates that the step has finished processing. Review BatchConstants in the batch API to see which return codes can be returned. A return code of BatchConstants.STEP_CONTINUE signals to the grid endpoints to continue calling this method in the batch loop. A return code of BatchConstants.STEP_COMPLETE indicates to the grid endpoints that the step has finished and to call destroyJobStep.
int destroyJobStep() Indicates to the step that completion has occurred. The integer return code of this method is arbitrary and can be chosen by the batch application developer. This return code is saved in the grid endpoints database and represents the return code of the batch step. If the results algorithm is associated with the batch job, then this return code is passed to it. If there is a return code-based conditional logic in the xJCL of the batch job, then the grid endpoints use this return code to evaluate that logic.

The getProperties() method on the BatchJobStepInterface is not currently called by the grid endpoints. The method is included in the interface for symmetry and possible later use.


Related concepts

  • Batch programming model
  • Batch controller bean
  • Batch data streams
  • Batch jobs and their environment


    Related tasks

  • Develop a simple transactional batch application