How to terminate Step within a Spring Batch Split Flow with a Decider

杀马特。学长 韩版系。学妹 提交于 2019-12-01 21:38:08

Given no answers from anyone on this, I'll proffer the hack that I'm using. It's not pretty, but neither is Spring.

Create a No Op Tasklet to use in a No Op step.

public class NoopTasklet implements Tasklet {
    @Override
    public RepeatStatus execute(final StepContribution contribution,
            final ChunkContext chunkContext) throws Exception {
        return RepeatStatus.FINISHED;
    }
}

The add NOOP tasklet to the decision block from the original example

<!-- Does nothing -->
<bean id="noopTasklet" class="com.foo.NoopTasklet" />

<!-- From example in question
<decision id="decideToRunStep04" decider="isStepNeededDecider" >
    <next on="RUN" to="step04"/>
    <next on="SKIP" to="noop01"/>
</decision>
<step id="step04">
    <!-- Conditionally do something-->
</step>
<step id="noop01">
    <!-- Does nothing in the SKIP case
    <tasklet ref="noopTasklet" />
</step>

Spring is the prettiest code in town. That said:

<step id="step1" parent="s1">
    <end on="FAILED" />
    <next on="COMPLETED WITH SKIPS" to="errorPrint1" />
    <next on="*" to="step2" />
</step>

as it is documented at http://docs.spring.io/spring-batch/reference/html/configureStep.html.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!