Make a spring-batch job exit with non-zero code if an exception is thrown

前端 未结 3 1253
醉梦人生
醉梦人生 2020-12-18 11:32

I\'m trying to fix a spring-batch job which is launched from a shell script. The script then checks the process exit code to determine whether the job has succeeded. Java, h

3条回答
  •  攒了一身酷
    2020-12-18 12:10

    I solved this some time ago - apologies that I did not update sooner.

    Spring Batch does exit non-zero on an failed job, but there's a subtle catch.

    If a job step has no transitions explicitly defined it will by default end the job on success and fail the job on failure (of the step).

    If, however, the step has a transition defined for any result (e.g. to the next step on success), there is no default transition for any other result, and if it fails the job won't be properly failed. So you have to explicitly define a "fail on FAILED" transition (typically, for all steps except the last).

提交回复
热议问题