How to make JobExecutionDecider complete with successful exit code

I have a problem with JobExecutionDecider exit code when "end on" is called. I use CommandLineJobRunner inside a shell script, where do I get the exit code via $? which indicates the exit status of the called program. The problem is that whenever the JobExecutionDecider "end on" is called, the exit status is invariably set to 1 (failure). This is not the case when "end on" is called through a regular "step". In these cases, the exit code is set appropriately (i.e. 0). I tried to manually set the end of the exit code to "COMPLETED" with the same results as shown below.

Note that the solution is actually a “preliminary step” and is the first thing that the task does. In the case where a decision has been made to complete processing, the actual "steps" are not performed.

from spring-config:

< job id="jobOne" /> < decision id="myDecision" decider="myDecider"> < end on="ABORT" exit-code="COMPLETED"/> < next on="CONTINUE" to="nextStep" /> < /decision> < step id="stepOne" /> < tasklet ref="myTasklet"> ... 

from the qualifier:

 public FlowExecutionStatus decide(JobExecution jobEx, StepExecution arg1) { if (abortExecution()) return new FlowExecutionStatus("ABORT"); return new FlowExecutionStatus("CONTINUE"); } 

Hope I have provided enough information. Any help would be greatly appreciated. Thank you

+4
source share
1 answer

CommandLineJobRunner uses SimpleJvmExitCodeMapper , which in turn only understands

  • completed
  • failed
  • job not found

and I'm pretty sure that the above configuration leaves the job with UNKNOWN status, this will be handled using exitCodeMapper with "I don’t know, I will return 1" (see .intValue () method)

but you can provide your own CommandLineJobrunner (just expand the source) and set your own implementation for exitCodeMapper

+2
source

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


All Articles