admin管理员组

文章数量:1122846

Context

I use Spring Batch and I use a JobExecutionDecider which can return two values "FAILED" or "COMPLETED" according to the writeCount value of the preceding step. Depending on the returned value of the decider, I execute then one step or another.

The Problem

But after I want to always execute a final step, whatever the decider choice. But I see that this final step is not executed when my decider chose one of the two steps.

  • How can I make two branches of my flow merge again and execute a common step ?

Below is a sample code. The step stepMergeWithUserValidateStatus is the one I want to always execute before the end. Should I duplicate the call to this step ?

@Bean
public Job job(JobRepository jobRepository, MyDecider decider,
               Step stepTruncateTable,
               Step stepReadProcessWrite,
               MyDecider receptionSucessDecider,
               Step stepRestoreFromBackup,
               Step stepBackupInsertedData,
               Step stepMergeWithUserValidateStatus) {
    return new JobBuilder("job", jobRepository)
            .start(stepTruncateTable)
            .start(stepReadProcessWrite)
            .next(receptionSucessDecider).on("FAILED").to(stepRestoreFromBackup)
            .from(receptionSucessDecider).on("COMPLETED").to(stepBackupInsertedData)
            .next(stepMergeWithUserValidateStatus) // Not called after execution of stepRestoreFromBackup
            .end()
            .build();
}

Thanks in advance for your help !

本文标签: jobexecutiondeciderSpring Batch Next JOIN Step AFTER deciderStack Overflow