The bottom line: I need the job to be stopped quickly (not just the steps), so
jobLauncher.run(job, jobParameters)
does not block for so long.
And now the details:
I have a simple job set up:
I launch the job inside a container:HTML Code:<job id="myJob" restartable="false" xmlns="http://www.springframework.org/schema/batch" job-repository="dbJobRepository"> <step id="myStep"> <tasklet> <chunk reader="myReader" processor="myProcessor" writer="myWriter" commit-interval="100"> </chunk> </tasklet> </step> </job>
The launcher.run() method blocks, as I run in synced mode.Code:class AbstractJob{ public Status run(...){ ... this.jobParameters = jobParamsBuilder.toJobParameters(); JobExecution jobExecution = jobLauncher.run(job, jobParameters); BatchStatus batchStatus = jobExecution.getStatus(); if (batchStatus == BatchStatus.COMPLETED) ... ... } public void abort(){ ... JobOperator jobOperator = KBeansProvider.getBean("jobOperator"); JobRepository jobRepository = KBeansProvider.getBean("dbJobRepository"); JobExecution jobExecution = jobRepository.getLastJobExecution(this.jobBeanId, this.jobParameters); try { jobOperator.stop(jobExecution.getJobId()); } ... }
Now, when I abort, I expect the call to return in a reasonable time, as the system is in idle state besides the job.
The step is indeed stopped, as can be seen in the log:
The batch_step_execution status is set to stopped in a matter of half a minute or so.Code:2012-02-12 18:36:14,649 INFO [org.springframework.batch.core.repository.support.SimpleJobRepository] - <Parent JobExecution is stopped, so passing message on to StepExecution> 2012-02-12 18:36:14,653 INFO [org.springframework.batch.core.step.ThreadStepInterruptionPolicy] - <Step interrupted through StepExecution> 2012-02-12 18:36:14,656 ERROR [org.springframework.batch.core.step.AbstractStep] - <Encountered an error executing the step> org.springframework.batch.core.JobInterruptedException: Job interrupted status detected. at org.springframework.batch.core.step.ThreadStepInterruptionPolicy.checkInterrupted(ThreadStepInterruptionPolicy.java:42) at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:277)
The problem is, the job itself is "stuck" in'STOPPING' mode.
Sometimes it gets stopped - but only after an unreasonable time, about 10 minutes, and sometimes it just stays in 'STOPPING' mode.
I also tried calling stop on the JobExecution itself, but it didn't solve it.
Thanks


Reply With Quote
