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"/>
</job>
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.JobFlowExecutor.executeStep(JobFlowExecutor.java:67)
at
org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
at
org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
at
org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281)
at
org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJ
obLauncher.java:120)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
at
org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJob
Launcher.java:114)
at
org.springframework.batch.core.launch.support.CommandLineJobRunner.start(Comm
 
 
Search WWH ::




Custom Search