Re-run same job with different parameters when launched via Quartz
Hi,
I tried the Quartz Example from the samples. As stated in documentation, the job gets executed the very first time and throws 'JobInstanceAlreadyCompleteException' when launched the next time.
But I need to run the job with different parameters when the job is launced via Quartz.
I followed the instructions on configuring incrementer on <job> as specified in chapter-4 Configuring and Running Job (4.5.4 JobParametersIncrementer)
Modified footBallJob.xml, used the incrementer.
Code:
<beans:bean id="dynamicJobParameters" class="org.springframework.batch.sample.common.DynamicJobParameters" />
<job id="footballJob" incrementer="dynamicJobParameters">
.....
.....
</job>
Now launched the quartz sample using 'JobRegistryBackgroundJobRunner' as specified. But I still get the below exception
Code:
org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException: A job instance already exists and is complete for parameters={}. If you want to run this job again, change the parameters.
at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy0.createJobExecution(Unknown Source)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:98)
at org.springframework.batch.sample.quartz.JobLauncherDetails.executeInternal(JobLauncherDetails.java:72)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Why does the job not using the incrementer ? Am I missing any other configuration ? Please suggest.
Thanks,
Madan Narra