
Originally Posted by
Dave Syer
If you wrote your own Tasklet and you want it to detect the signal itself then you just look at the StepExecution periodically inside your own code and react to it as you see fit. That should deal with "issue 1" above.
Thanks for that Dave. There's actually an issue with your suggested fix to "issue 1". I tried that yesterday before I sent off my second post but that didn't work.
The way I transfer these big files is I have a Tasklet step transfer them one by one. To test the scenario I've described above I use threads and run them side by side, the first one runs the job (and the steps) while the second thread controls the suspension and resumption (through stop and restart methods of the JobOperator) of the job. Inside the execute method of the Tasklet implementation class I've written, I periodically checked to see if the value of StepExecution's status has changed to "Stopped". The status' value remained in "Started" status even until before my application exited the Tasklet's execute method. Only after it exited the execute method did I see the stacktrace for the JobInterruptedException
Code:
13:00:57,434 DEBUG [Thread-8] FileCopyTask: Finished up the FileCopyTask at 44 seconds 127 millis
13:00:57,435 DEBUG [Thread-8] FileCopyTask: ************************** exiting execute method - status is: STARTED
13:00:57,484 ERROR [Thread-8] ThreadStepInterruptionPolicy: Step interrupted
13:00:57,487 ERROR [Thread-8] 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:44)
at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:365)

Originally Posted by
Dave Syer
You could also use your Tasklet to manipulate the ExecutionContext of the step, so that you drop something in there that you recognise on open() to avoid duplicate processing (assuming your Tasklet is an ItemStream). That would probably be my starting point if I was implementing your use case.
Thanks for the suggestion, I'll probably go with your "write something in the ExecutionContext" approach to avoid rerunning the step that has finished, once "issue 1" has been sorted. Any ideas on how that can be fixed?
The "stopping a job section" http://static.springsource.org/sprin...l#stoppingAJob says that there's no way of catching the "stopped" status from within the developer code. Only when the control is returned to the framework will the application know that the job has been stopped. If this is the case, then I might not really have a way of catching the stop signal from the execute method of my Tasklet?
Thanks again.