我有myFailedTask
2 个步骤的组合任务,其中一个配置为始终失败:
<mf1: sampleTask --fail=true --custom-argument=m || sampleTask>
第一次运行时,作业以run.id
等于1运行,并mf1
报告为失败。下次我运行 CTR 时,作业再次 以run.id
等于1sampleTask
的方式运行,并 跳过步骤:
2017-11-29 15:30:30.146 INFO 11604 --- [ taskExecutor-2] o.s.batch.core.job.SimpleStepHandler : Step already complete or not restartable, so no action to execute: StepExecution: id=97, version=3, name=myFailedTask-sampleTask_0, status=COMPLETED, exitStatus=COMPLETED, readCount=0, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=1, rollbackCount=0, exitDescription=
我正在使用使用httpclient
以下属性文件部署的转换器执行 CTR:
app.httpclient.body-expression='name='+new com.fasterxml.jackson.databind.ObjectMapper().readTree(payload).findValue('taskName').asText()+ \
'&arguments=\
--increment-instance-enabled=true \
--split-thread-core-pool-size=10 \
--interval-time-between-checks=5000 \
--composed-task-arguments=--message='+new String(T(java.util.Base64).getEncoder().encode(payload.getBytes()))
app.httpclient.http-method=POST
app.httpclient.url=http://localhost:9393/tasks/executions
app.httpclient.headers-expression={'Content-Type':'application/x-www-form-urlencoded'}
我还在--composed-task-arguments
CTR 调用之间通过不同的有效负载更改了 - 效果相同。
所以,我的问题是如何强制 CTR 运行新作业,而不是从失败的步骤继续之前失败的作业。
更新
好的,深入研究 spring 源代码,下面的代码JobLauncherCommandLineRunner::getNextJobParameters
解释了这种行为:
if (isStoppedOrFailed(previousExecution) && job.isRestartable()) {
// Retry a failed or stopped execution
parameters = previousExecution.getJobParameters();
// Non-identifying additional parameters can be removed to a retry
removeNonIdentifying(additionals);
}
else if (incrementer != null) {
// New instance so increment the parameters if we can
parameters = incrementer.getNext(previousExecution.getJobParameters());
}
所以我改写原来的问题:“我怎样才能将restartable
属性传递给 CTR ?