tmalvey
tmalvey

Reputation: 43

how to make JobExecutionDecider end with successful exit code

I have a issue regarding the exit code of the JobExecutionDecider when "end on" is invoked. I'm using the CommandLineJobRunner inside of a shell script where I get the exit code via $? which indicates the exit status of the called program. Problem is, whenever the JobExecutionDecider "end on" is invoked, the exit status is invariably set to 1 (failed). This is not the case when "end on" is invoked via a normal "step". In those cases, the exit code is set appropriately (i.e. 0). I've tried manually setting the end on exit code to "COMPLETED" with the same results as show below.

Note that the decision is actually a "pre-step" and is the first thing executed by the job. In the case where the decision is made to end processing, there are no actual "steps" executed.

from the 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 decider:

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

 return new FlowExecutionStatus("CONTINUE");
}

Hope I've provided enough info. Any help would be appreciated. Thanks.

Upvotes: 4

Views: 6914

Answers (1)

Michael Pralow
Michael Pralow

Reputation: 6630

the CommandLineJobRunner uses a SimpleJvmExitCodeMapper which in turn understands only

  • completed
  • failed
  • job not found

and i'm almost sure the above configuration leaves the job with status UNKNOWN, this will be handled from the exitCodeMapper with a "don't know this, i will return 1" (see .intValue() method)

but you can provide your own CommandLineJobrunner (just extend the original one) and set an own implementation for the exitCodeMapper

Upvotes: 2

Related Questions