How to complete step in Spring batch flow-sharing with solution

The following design flaw occurred in Spring Batch.

  • The step must have the Next attribute, if this is not the last step or the last step of the separation stream.
  • The decision block must handle all cases returned by the Decision.

Because of this, in Split Flow, where in the last step there will be no Next attribute, if there is a Decision protecting it, then it should have the Next attribute. Therefore, it should not have this attribute, but it also needs it. Catch 22.

Example:

<!-- Process parallel steps -->
<split id="split01">
    <flow>
        <step id="step1" next="step02">
            <!-- Do something -->
        </step>
        <step id="step02">
            <!-- Do something else -->
        </step>
    </flow>
    <flow>
        <step id="step03">
            <!-- Do something -->
        </step>

        <!-- Only run under specific conditions -->
        <decision id="decideToRunStep04" decider="isStepNeededDecider" >
            <next on="RUN" to="step04"/>
            <!-- Other state is "SKIP" -->
        </decision>
        <step id="step04">
            <!-- Conditionally do something-->
        </step>
    </flow>
</split>

<step id="step05" >
    <!-- Some more stuff -->
</step>

This is similar to what the Spring guys would think, so it's curious what the right, non-hack way to achieve this is. Thank.

+3
source share
2 answers

- , , . , Spring.

No Op Tasklet No Op.

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

NOOP

<!-- 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>
+8

Spring - . :

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

http://docs.spring.io/spring-batch/reference/html/configureStep.html.

+2

All Articles