运行 Spring 云数据流中的批处理任务时出现 JobInstanceAlreadyCompleteException
JobInstanceAlreadyCompleteException when running a Batch-Task in Spring cloud Dataflow
我有一个批处理作业作为 spring 云数据流中的任务。当我第二次尝试执行相同的任务定义时,出现异常:
java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:793)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:774)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
at com.tigerbooks.importer.ImportTask.main(ImportTask.java:20)
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.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException: A job instance already exists and is complete for parameters={-spring.cloud.task.executionid=3, -spring.datasource.username=dataflow_stage, -spring.datasource.url=jdbc:mysql://10.59.254.101:3306/dataflow_staging, -spring.datasource.driverClassName=org.mariadb.jdbc.Driver, -import.import-audio-content=false, -spring.datasource.password=bVs64CMlKvcTdkRLWL2zNPANYD3HMB, -import.syncfolder=/import-integrationtest, -spring.cloud.task.name=Integration-Test, -spring.profiles.active=ftp01,dev}. If you want to run this job again, change the parameters.
at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:130)
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:338)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java
我的作业配置如下所示:
@EnableBatchProcessing
public class JobConfiguration {
@Bean
public Job importJob() {
return jobBuilderFactory.get("Import-Products").incrementer(new RunIdIncrementer())
.flow(step1())
.next(step2())
.end()
.build();
}
}
据我所知,JobParametersIncrementor 应该通过向参数添加递增的 运行Id 来修复此异常。但在我的情况下,我只能 运行 服务器上的作业一次,然后我必须清除数据库 (mysql) 并且数据库中没有 RunId。
因为@Michael Minela 已经猜到我的工作是从错误的地方开始的 docker image-version。所以 RunIdIncrementer 不存在,它没有工作。
使用正确版本注册新应用后,一切正常。谢谢。
我有一个批处理作业作为 spring 云数据流中的任务。当我第二次尝试执行相同的任务定义时,出现异常:
java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:793)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:774)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
at com.tigerbooks.importer.ImportTask.main(ImportTask.java:20)
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.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException: A job instance already exists and is complete for parameters={-spring.cloud.task.executionid=3, -spring.datasource.username=dataflow_stage, -spring.datasource.url=jdbc:mysql://10.59.254.101:3306/dataflow_staging, -spring.datasource.driverClassName=org.mariadb.jdbc.Driver, -import.import-audio-content=false, -spring.datasource.password=bVs64CMlKvcTdkRLWL2zNPANYD3HMB, -import.syncfolder=/import-integrationtest, -spring.cloud.task.name=Integration-Test, -spring.profiles.active=ftp01,dev}. If you want to run this job again, change the parameters.
at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:130)
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:338)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java
我的作业配置如下所示:
@EnableBatchProcessing
public class JobConfiguration {
@Bean
public Job importJob() {
return jobBuilderFactory.get("Import-Products").incrementer(new RunIdIncrementer())
.flow(step1())
.next(step2())
.end()
.build();
}
}
据我所知,JobParametersIncrementor 应该通过向参数添加递增的 运行Id 来修复此异常。但在我的情况下,我只能 运行 服务器上的作业一次,然后我必须清除数据库 (mysql) 并且数据库中没有 RunId。
因为@Michael Minela 已经猜到我的工作是从错误的地方开始的 docker image-version。所以 RunIdIncrementer 不存在,它没有工作。
使用正确版本注册新应用后,一切正常。谢谢。