Chapter 10. Controlling execution

 

This chapter covers

  • Controlling a job’s execution path
  • Sharing data between job steps at runtime
  • Externalizing job definitions for reuse
  • Choosing how to stop a job after executing a step

Writing batch applications isn’t an easy task. Previous chapters covered how to read and write data efficiently with Spring Batch. These chapters also covered error handling during processing by skipping errors or retrying operations transparently. This chapter covers mastering job execution with Spring Batch. What do we mean by job execution?

A job consists of steps, and execution refers to the sequence of steps that run when a job starts. In simple jobs, the sequence of steps is linear. In complex jobs, execution can take multiple paths, and the sequence is no longer linear. Figure 10.1 shows the structure of a simple, linear job and a more complex, nonlinear job.

Figure 10.1. Jobs with linear and nonlinear flows. Job A, on the left, has a simple linear flow. Job B, on the right, isn’t linear because there are multiple execution paths.

Because batch jobs must run automatically, without human intervention, we need a way to configure a step sequence so that a job knows which step to execute next.

10.1. A complex flow in the online store application

10.2. Driving the flow of a job

10.3. Sharing data between steps

10.4. Externalizing flow definitions

10.5. Stopping a job execution

10.6. Summary

sitemap