Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
spring批处理:条件流_Spring_Spring Batch - Fatal编程技术网

spring批处理:条件流

spring批处理:条件流,spring,spring-batch,Spring,Spring Batch,我需要根据工作步骤1中的某些条件来决定下一步调用哪个步骤 请注意:在步骤1中,我使用的是纯tasklet方法。例如: <step id="step1"> <tasklet ref="example"> </step> 请帮助,我如何在示例tasklet中添加一些代码或进行一些配置以决定下一步要调用的步骤 我已经研究了您可以在上下文文件中指定流控制,如下所示: <step id="step1"> <tasklet ref="

我需要根据工作步骤1中的某些条件来决定下一步调用哪个步骤

请注意:在步骤1中,我使用的是纯tasklet方法。例如:

<step id="step1">
   <tasklet ref="example">
</step>

请帮助,我如何在示例tasklet中添加一些代码或进行一些配置以决定下一步要调用的步骤


我已经研究了您可以在上下文文件中指定流控制,如下所示:

<step id="step1">
    <tasklet ref="example">
    <next on="COMPLETED" to="step2" />
    <end on="NO-OP" />
    <fail on="*" />
    <!-- 
      You generally want to Fail on * to prevent 
      accidentally doing the wrong thing
    -->
</step>

返回新的ExitStatus(“失败”);你是说*?不,因为“*”是上下文文件中的通配符。除了
已完成
无操作
之外,我本可以返回任何东西使作业失败
public class SampleTasklet implements Tasklet, StepExecutionListener {

    @Override
    public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
        // do something
        return RepeatStatus.FINISHED;
    }

    @Override
    public void beforeStep(StepExecution stepExecution) {
        // no-op
    }

    @Override
    public ExitStatus afterStep(StepExecution stepExecution) {
        //some logic here
        boolean condition1 = false;
        boolean condition2 = true;

        if (condition1) {
            return new ExitStatus("COMPLETED");
        } else if (condition2) {
            return new ExitStatus("FAILED"); 
        }

        return new ExitStatus("NO-OP");
    }

}