Java Reference
In-Depth Information
Listing 6-40. Configuring a Step to Be Reexecuted if Complete
<step id="importTransactionFileStep">
<tasklet allow-start-if-complete="true">
<chunk reader="transactionFileReader" writer="transactionWriter"
commit-interval="10">
<streams>
<stream ref="fileItemReader"/>
</streams>
</chunk>
<listeners>
<listener ref="transactionFileReader"/>
</listeners>
</tasklet>
</step>
In this case, when the step is executed for the second time within a job that failed or was stopped on
the previous execution, the step starts over. Because it completed the previous time, there is no middle
ground at which to restart, which is why it begins again at the beginning.
Note If the job has the ExitStatus of COMPLETE , the JobInstance can't be rerun regardless of whether you
configure all the steps to allow-start-if-complete="true" .
When you're configuring batch processes, Spring Batch offers many different options for stopping
and restarting jobs. Some scenarios can have the full job reexecuted. Others can be tried again, but only
a given number of times. And some can't be restarted at all. However, it's you, the developer, who must
design your batch jobs in a way that is safe for your scenario.
Summary
Starting or stopping a program isn't a topic that typically gets much press. But as you've seen,
controlling the execution of a Spring Batch process provides many options. And when you think about
the variety of scenarios that must be supported by batch processes, those options make sense.
The next section of this topic covers the meat of the framework: ItemReaders, ItemProcessors, and
ItemWriters.
 
Search WWH ::




Custom Search