배치 작업을 처리하기 위해 Spring 배치를 사용하려고합니다. 내가 stop
에 executionId
을 사용하여 실행중인 작업을하려고하면 는 작업이 2017년 11월 27일 11시 39분 ',스프링 부트 JobOperator.stop (executionId) 및 JobOperator.restart (executionId) 동작
'104 ','3 ','104 '
SpringBatchDb.BATCH_JOB_EXECUTION
표에 아래의 항목과 정지 : 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 다음STATUS
및EXIT_CODE
가STOPPED
으로 업데이트됩니다 NULL (48) ',
참고. 그러나 예외로 throw합니다 : 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);
}
매우 간단하다?