Monday, March 15, 2010

Steps Execution in Spring Batch

In the real world scenario a batch task may need more than one step to complete the processing. The steps may or may not be independent of each other. Spring batch provides provision to define multiple steps for a Job.Each Step has a StepExecutionContext which provides the Information about the status of the step.The order of the steps execution can be made conditional

When a job consists of multiple steps ,it may be necessary to pass information between the steps. Each Step has a StepExecutionContext but this exists only for the span of the step. To make the data available to future Steps, it will have to be passed to the Job ExecutionContext after the step has finished. Spring Batch provides the ExecutionContextPromotionListener for this purpose. The listener must be configured with the keys related to the data in the ExecutionContext that must be promoted and must be registered with the Step.

The sample of Job with multiple steps

3 comments:

  1. Here is my xml content from jobConfig.xml,
    When I run the test, I get the error saying "The element [processFile2Step] is unreachable"

    when I switched the steps, it complains about
    "The element [emailStep] is unreachable"

    Any thoughts ???

    ReplyDelete
  2. Somehow not taking XML here.

    I have 2 different steps, it always complains about second one not reachable.

    ReplyDelete
  3. your image is not visible here.. better to post a sample project. That would really help!

    ReplyDelete