我在开发Spring Batch时正在学习。要求是;如果我必须在处理过程中终止该过程; 批次应该可以从停下来的地方取货。批处理基于日期范围和处理从数据库表中读取数据 并在处理完后写入另一个表。
我已将作业标记为restartable = true。出于测试目的,当我在本地完全杀死工作(流程)时。 我使用下面的sql将job_execution_id和step_execution_id的状态更新为“ FAILED”
update batch_job_execution
set status = 'FAILED'
where job_execution_id = '226'
update batch_step_execution
set status = 'FAILED'
where step_execution_id = 1357
其中批处理作业的最后一个作业执行ID为226,作业实例ID为198,其对应的步骤执行为1357
但是工作仍然低于
org.springframework.batch.core.launch.support.SimpleJobLauncher.java line number 131
jobExecution = jobRepository.createJobExecution(job.getName(), jobParameters);
Exception thrown
org.springframework.batch.core.repository.JobExecutionAlreadyRunningException: A job execution for this job is already running: JobInstance: id=198, version=0, Job=[XYZ]
at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean$1.invoke(AbstractJobRepositoryFactoryBean.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy6.createJobExecution(Unknown Source)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:131)
at com.XYZ.main.AppMain.main(AppMain.java:43)