From the course: Spring: Spring Batch

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Reusability in batch jobs

Reusability in batch jobs

From the course: Spring: Spring Batch

Start my 1-month free trial

Reusability in batch jobs

- [Instructor] When building batch jobs, there may be consecutive sequences of steps that need to appear in every job you build. When this situation occurs it is important to remember the DRY principle, do not repeat yourself. To help us adhere to this principle, Spring Batch provides us with two strategies to reuse jobs and common step sequences. If we look at these two jobs, we can see they are not exactly the same, but there is some repetition in the flow because both jobs execute Step B and Step C in sequence. This part of the flow can be externalized into a separate flow and defined as a Bean using Spring Batch's Flow Builder. Once an external flow is constructed, both jobs can execute the flow using a flow step within their configuration allowing the same flow to be reused in multiple jobs. Using external flows is a better approach in this scenario because if Step B needed to change, the changes could be made in one…

Contents