Java Reference
In-Depth Information
The next option for externalizing steps is to use the flow step. With this technique, the configuration
of a flow is the same. But instead of using the flow tag to include the flow in your job, you use a step tag
and its flow attribute. Listing 4-47 demonstrates how to use a flow step to configure the same example
Listing 4-46 used.
Listing 4-47. Using a Flow Step
<flow id="preProcessingFlow">
<step id="loadFileStep" next="loadCustomerStep">
<tasklet ref="loadStockFile"/>
<step id="loadCustomerStep" next="updateStartStep">
<tasklet ref="loadCustomerFile"/>
<step id="updateStartStep">
<tasklet ref="updateStart"/>
<job id="flowJob">
<step id="initializeBatch" next="runBatch">
<flow parent="preProcessingFlow"/>
<step id="runBatch">
<tasklet ref="runBatchTasklet"/>
What is the difference between using the flow tag and the flow step? It comes down to what happens
in the JobRepository . Using the flow tag ends up with the same results as if you configured the steps in
your job. Using a flow step adds an additional entry. When you use a flow step, Spring Batch records the
step that includes the flow as a separate step. Why is this a good thing? The main benefit is for
monitoring and reporting purposes. Using a flow step allows you to see the impact of the flow as a whole
instead of having to aggregate the individual steps.
The last way to externalize the order in which steps occur is to not externalize them at all. In this
case, instead of creating a flow, you call a job from within another job. Similar to the flow step, which
creates a StepExecutionContext for the execution of the flow and each step within it, the job step creates
a JobExecutionContext for the step that calls the external job. Listing 4-48 shows the configuration of a
job step.
Listing 4-48. Using a Job Step
<job id="preProcessingJob">
<step id="step1" parent="loadStockFile" next="step2"/>
<step id="step2" parent="loadCustomerFile" next="step3"/>
<step id="step3" parent="updateStartOfBatchCycle"/>
<beans:bean id="jobParametersExtractor"
Search WWH ::

Custom Search