Java Reference
In-Depth Information
xsi:schemaLocation="
http://www.springframework.org/schema/beans
<beans:import resource="../launch-context.xml"/>
<beans:bean id="passTasklet"
class="com.apress.springbatch.chapter4.LogicTasklet">
<beans:property name="success" value="false"/>
</beans:bean>
<beans:bean id="successTasklet"
class="com.apress.springbatch.chapter4.MessageTasklet">
<beans:property name="message" value="The step succeeded!"/>
</beans:bean>
<beans:bean id="failTasklet"
class="com.apress.springbatch.chapter4.MessageTasklet">
<beans:property name="message" value="The step failed!"/>
</beans:bean>
<job id="conditionalStepLogicJob">
<step id="step1">
<tasklet ref="passTasklet"/>
<end on="*"/>
<next on="FAILED" to="step2b"/>
</step>
<step id="step2b">
<tasklet ref="failTasklet"/>
</step>
</job>
</beans:beans>
Once you run
conditionalStepLogicJob
, as you would expect, the
batch_step_execution
table
contains the
ExitStatus
returned by the step, and
batch_job_execution
contains
COMPLETED
regardless of
the path taken.
For the failed state, which allows you to rerun the job with the same parameters, the configuration
looks similar. Instead of using the
end
tag, you use the
fail
tag. Listing 4-44 shows that the
fail
tag has
an additional attribute:
exit-code
. It lets you add extra detail when causing a job to fail.
Listing 4-44.
Ending a Job in the Failed State
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="
http://www.springframework.org/schema/batch"
xmlns:beans="
http://www.springframework.org/schema/beans"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans