Java Reference
In-Depth Information
<beans:import resource="../launch-context.xml"/>
<beans:bean id="passTasklet"
class="com.apress.springbatch.chapter4.LogicTasklet">
<beans:property name="success" value="true"/>
</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"/>
<next on="*" to="step2a"/>
<fail on="FAILED" exit-code="STEP-1-FAILED"/>
</step>
<step id="step2a">
<tasklet ref="successTasklet"/>
</step>
</job>
</beans:beans>
When you rerun conditionalStepLogicJob with the configuration in Listing 4-44, the results are a bit
different. This time, if step1 ends with the ExitStatus FAILURE , the job is identified in the jobRepository
as failed, which allows it to be reexecuted with the same parameters.
The last state you can leave a job in when you end it programmatically is the stopped state. In this
case, you can restart the job; and when you do, it restarts at the step you configure. Listing 4-45 shows an
example.
Listing 4-45. Ending a Job in the Stopped 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
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
<beans:import resource="../launch-context.xml"/>
<beans:bean id="passTasklet"
class="com.apress.springbatch.chapter4.LogicTasklet">
<beans:property name="success" value="true"/>
 
Search WWH ::




Custom Search