我有一天会搜索这些问题,有些代码是这样的:
JobOperator jobOperator = BatchRuntime.getJobOperator();
jobOperator.stop(Long jobId);
但是在作业运行时我找不到jobId。
你有什么想法吗?感谢答案 0 :(得分:0)
我已经解决了这个问题。
public class StepExecutionListener implements org.springframework.batch.core.StepExecutionListener {
@Override
public void beforeStep(StepExecution stepExecution) {
JobExecution jobExecution = stepExecution.getJobExecution();
Long id = jobExecution.getId();
JobParameters jobParameters = jobExecution.getJobParameters();
String topicId = jobParameters.getString("topicId");
String appId = jobParameters.getString("appId");
JobHelper.jobIdMap.put(topicId + appId, id);
}
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
return null;
}
}
,我们需要在步骤中添加监听器。