java - 由于 JobExecutionAlreadyRunningException 导致批处理作业失败:此作业的作业执行已在运行
问题描述
如何从主要方法停止批处理作业?我正在从我的方法运行批处理作业,现在它给了我以下错误。关于如何杀死和阻止它的任何帮助?
A job execution for this job is already running: JobInstance: id=18380, version=0, Job=[myFileGenerationJob]
org.springframework.batch.core.repository.JobExecutionAlreadyRunningException: A job execution for this job is already running: JobInstance: id=18380, version=0, Job=[myFileGenerationJob]
Done
at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:280)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean$1.invoke(AbstractJobRepositoryFactoryBean.java:172)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy3.createJobExecution(Unknown Source)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:125)
at com.mastercard.ess.eds.CustomerFileGenerationApp.main(CustomerFileGenerationApp.java:31)
我正在使用以下代码 -
public class CustomerFileGenerationApp {
public static void main(String[] args) {
PropertyConfigurator.configure("src/main/resources/log4j.properties");
String[] springConfig = { "../META-INF/spring/customer-file-generation-job.xml"};
ApplicationContext context = new FileSystemXmlApplicationContext(springConfig);
JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
Job job = (Job) context.getBean("customerFileGenerationJob");
JobParameters jobParameters = new JobParametersBuilder().addString("runMode", "ABCD").toJobParameters();
try {
JobExecution execution = jobLauncher.run(job, jobParameters);
System.out.println("Exit Status : " + execution.getStatus());
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
System.out.println("Done");
}
}
解决方案
推荐阅读
- javascript - 无法将文件从 React 上传到具有多个对象的 .net Core 5
- mongodb - Mongodb:如何将 $facet 输出 2 与 2 合并?
- java - 将 https 添加到缺少的数组字符串中?
- javascript - MMM-CalendarExt2 在 MagicMirror2 上导致黑屏
- google-bigquery - 如何使用 bigquery 测试字符串是否在带有通配符的字符串列表中
- vue.js - 如何处理 Vuex/Pinia 商店中的关系并保持同步?
- regex - 在 Vue.js 中格式化不同的信用卡类型(15 位或 16 位)
- python - 用 Python 收集视频数据
- python - 如何使列表具有一定的大小(k)
- flutter - Flutter SliverGrid 翻转轴