Spring Execution step (java-config) after executing the ExeuctionDecider task

I am trying to configure a thread in a spring package using java-config, this thread should basically do this:

  • Perform the init step (which adds the entry to the database)

  • then execute the solution to check the existence of the file,

2.1. If the files exist, it will execute the download task (this is another thread with a parallel bunch of steps)

  1. Perform the completion step (which adds the record to the database), this should always be done, even if 2.1 has not been completed.

I tried to complete this setup, but the completion step never starts:

Flow flow = new FlowBuilder<SimpleFlow>("commonFlow") .start(stepBuilderFactory.get("initStep").tasklet(initTasklet).build()) .next(decider) .on(FlowExecutionStatus.COMPLETED.getName()) .to(splitFlow) .from(decider).on("*") .end() .next(stepBuilderFactory.get("finishStep").tasklet(finishTasklet).build()) .end(); 

I can make it work as shown below, but it is not elegant:

  Step finishStep = stepBuilderFactory.get("finishStep").tasklet(finishTasklet).build(); Flow flow = new FlowBuilder<SimpleFlow>("commonFlow") .start(stepBuilderFactory.get("initStep").tasklet(initTasklet).build()) .next(decider) .on(FlowExecutionStatus.COMPLETED.getName()) .to(splitFlow) .next(finishStep) .from(decider).on("*") .to(finishStep) .end(); 

Does anyone know how to correctly complete the step after making a decision using java-config?

+5
source share
1 answer

It seems that this is being done much more difficult than necessary. You do not need to tune the flow or make decisions. This is a VERY simple job and work.

The easiest option is to use Spring Integration to detect the gifts of the file and run the task.

The next simplest option is to simply check the operation of quartz or CRON for the file and run the batch job.

Last but not least, you can run the task and if ItemReader cannot find the file (s), just swallow the exception. Or install a FileItemReader listener to check the files in front of it.

+1
source

Source: https://habr.com/ru/post/1210191/


All Articles