【发布时间】:2018-05-10 08:57:01
【问题描述】:
我正在尝试使用 Spring 批处理来处理批处理作业。
当我尝试使用executionId stop 一个正在运行的作业时,该作业在SpringBatchDb.BATCH_JOB_EXECUTION 表中的以下条目中停止
'104','3','104','2017-11-27 11:39:10','2017-11-27 11:39:10','2017-11-27 11:39 :48','STOPPED','STOPPED','org.springframework.batch.core.JobInterruptedException','2017-11-27 11:39:48',NULL
请注意,STATUS 和 EXIT_CODE 已更新为 STOPPED。但它会抛出一个异常,org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [testJob] was registered
at org.springframework.batch.core.configuration.support.MapJobRegistry.getJob(MapJobRegistry.java:66)
at org.springframework.batch.core.launch.support.SimpleJobOperator.restart(SimpleJobOperator.java:275)
at org.springframework.batch.core.launch.support.SimpleJobOperator$$FastClassBySpringCGLIB$$44ee6049.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:669)
at org.springframework.batch.core.launch.support.SimpleJobOperator$$EnhancerBySpringCGLIB$$318ff269.restart(<generated>)
at com.test.mypackage.batch.dao.BatchJobDaoImpl.restartJobExecution(BatchJobDaoImpl.java:62)。
当我尝试使用 executionId 重新启动同一个作业时,它无法启动并给出相同的异常(如上所示)。
我的代码很简单,
@Autowired
private DataSource dataSource;
@Autowired
private JobOperator jobOperator;
@Override
public Long stopRunningExecution(Long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException {
jobOperator.stop(executionId);
return executionId;
}
@Override
public Long restartJobExecution(long executionId) throws JobParametersInvalidException, JobRestartException, JobInstanceAlreadyCompleteException, NoSuchJobExecutionException, NoSuchJobException {
return jobOperator.restart(executionId);
}
这里有什么问题?
【问题讨论】:
标签: spring spring-mvc spring-boot spring-batch