+

Search Tips   |   Advanced Search

Implement the error tolerant step (ThresholdBatchStep)

An error tolerant generic batch step works with one input, one output stream, and one error stream. This step during each iteration of the batch loop reads a single entry from the batch data stream (BDS) input stream and passes it to the BatchRecordProcessor property for processing.

The BatchRecordProcessor property might either return a valid data object or a null value in a tolerable error. If the returned value is null, the record read from the input stream is logged on to the error stream and the invalidRecordEncountered method is invoked on the ThresholdPolicy interface. The threshold policy determines whether the error tolerance threshold has been reached. If so, it returns STEP_CONTINUE_FORCE_CHECKPOINT_BEFORE_PROCESSING_CANCEL, which forces a checkpoint and puts the job in the restartable state. Otherwise, the job continues as normal. If the data returned by BatchRecordProcessor.processRecord is valid, then the data is passed to the BDS output stream.

Use the following properties to implement the error tolerant step.

Property name Value Description
threshold_policy Java class name Class implementing the com.ibm.websphere.batch.devframework.thresholdpolicies.ThresholdPolicy interface
BATCHRECORDPROCESSOR Java class name Class implementing the BatchRecordProcessor interface

Property Value Description
debug true or false (default is false) Enable tracing and debugging on the step
EnablePerformanceMeasurement true or false (default is false) Measure time spent within the step

  1. Implement the interface com.ibm.websphere.batch.devframework.steps.technologyadapters.BatchRecordProcessor to provide the business logic for the step.

    In the xJCL for the step, declare a property BATCHRECORDPROCESSOR with the value set to the implementation of the interface. For example:

    ...
    <props>   <prop name="BATCHRECORDPROCESSOR"
        value="com.ibm.websphere.batch.samples.tests.steps.InfrastructureVerificationTest"/>
    </props>
    ...    

  2. Implement the interface com.ibm.websphere.batch.devframework.thresholdpolicies.ThresholdPolicy to provide the threshold policy for the step. We can also use the product implementations such as com.ibm.websphere.batch.devframework.thresholdpolicies.PercentageBasedThresholdPolicy or com.ibm.websphere.batch.devframework.thresholdpolicies.RecordBasedThresholdPolicy.

    Declare the ThresholdPolicy to use in the xJCL as shown in the following code snippet:

    ...   <props>    <prop name="threshold_policy"
        value="com.ibm.websphere.batch.devframework.thresholdpolicies.PercentageBasedThresholdPolicy"/>  </props>  ...  

  3. Set the BDS input stream logical name to inputStream and a BDS output stream logical name to outputStream and the BDS output stream for errors to errorStream.

    The logical names are declared in the xJCL. For example:

    <batch-data-streams>
       <bds>
     <logical-name>inputStream</logical-name>
     <props>
            ....     </bds>
        <bds>
     <logical-name>outputStream</logical-name>
     <props>
     ...
        </bds>
        <bds>
     <logical-name>errorStream</logical-name>
     <props>
     ...
         </bds>
    </batch-data-streams>

  4. While using the BatchPackager for packaging, the application for the job step class, jobstepclass, must be set to com.ibm.websphere.batch.devframework.steps.technologyadapters.ThresholdBatchStep. For Example :

    Use WebSphere Extended Deployment Compute Grid Version 6.1.1:

    ejbname.1=IVTStep1
    jndiname.1=ejb/MyThresholdBatchStep
    jobstepclass.1=com.ibm.websphere.batch.devframework.steps.technologyadapters.ThresholdBatchStep

    Using WebSphere Extended Deployment Compute Grid Version 8.0:

    ...
    <job-step name="Step1">
    <classname>com.ibm.websphere.batch.devframework.steps.technologyadapters.ThresholdBatchStep</classname>
    ...


Related concepts

  • Batch data stream framework and patterns


    Related tasks

  • Develop a simple transactional batch application