没有参数的春季批处理作业

时间:2020-06-03 15:04:59

标签: spring-batch

创建没有任何参数的spring batch作业是一种好习惯吗?

首次启动
我第一次批量启动了3个步骤:

Executing step: [step1]
Executing step: [step2]
Executing step: [step3]
myJob completed with the following parameters: [{}] and the following status: [COMPLETED]

如何在完成执行后重新启动此类批处理?
如果我测试了,我会得到:

Step already complete or not restartable, so no action to execute
Step already complete or not restartable, so no action to execute
Step already complete or not restartable, so no action to execute
myJob completed with the following parameters: [{}] and the following status: [COMPLETED]

所以我不能重启这样的批处理吗?
如果我在每个步骤中添加allowStartIfComplete(true),它们将被重新执行:

Executing step: [step1]
Executing step: [step2]
Executing step: [step3]
myJob completed with the following parameters: [{}] and the following status: [COMPLETED]

很好,但是...

如果批处理失败怎么办?
想象第二步失败:

Executing step: [step1]
Executing step: [step2]
Encountered an error executing step step2
myJob completed with the following parameters: [{}] and the following status: [FAILED]

如果我重新启动失败的批次

Executing step: [step1]
Executing step: [step2]
Executing step: [step3]
myJob completed with the following parameters: [{}] and the following status: [COMPLETED]

是的,但我不希望第一步重新执行????
实际上,我只想从失败的步骤中恢复批处理。
所以我必须删除allowStartIfComplete ...

我想要的是明确的:

  • 如果作业的状态为“已完成”,我想轻松地通过所有步骤重新启动他
  • 如果作业失败,我想在失败的步骤重新启动他

没有参数批处理是否可能?
作业有“ allowStartIfComplete”吗?
我必须使用JobParametersIncrementer吗?

0 个答案:

没有答案