Java Reference
In-Depth Information
Although the code is only marginally cleaner (you eliminate the else statement—that's it), the
configuration becomes cleaner as well by allowing you to remove the configuration required for the
transitions. Listing 6-31 shows the updated job configuration.
Listing 6-31. Reconfigured transactionJob
<job id="transactionJob">
<step id="step1" parent="importTransactionFileStep" next="step2"/>
<step id="step2" parent="applyTransactionsStep" next="step3"/>
<step id="step3" parent="generateAccountSummaryStep"/>
You can now execute the job again with the same test (running it the first time with an incorrect
number of records in the transaction file and then a second time with the correct number) and see the
same results. The only difference is in the output of the job on the console. Instead of the job returning a
STOPPED status, Spring Batch throws a JobInterruptedException , as shown in Listing 6-32.
Listing 6-32. Results of the First Execution of your updated job
2011-01-11 20:08:04,724 ERROR
[org.springframework.batch.core.job.AbstractJob] - <Encountered interruption
executing job>
org.springframework.batch.core.JobInterruptedException: Step requested
termination: StepExecution: id=6379, version=4, name=step1, status=COMPLETED,
exitStatus=COMPLETED, readCount=100, filterCount=0, writeCount=100
readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=2,
rollbackCount=0, exitDescription=
at org.springframework.batch.core.job.flow.FlowJob.doExecute(
at org.springframework.batch.core.job.AbstractJob.execute(
at org.springframework.core.task.SyncTaskExecutor.execute(
Search WWH ::

Custom Search