I am new to spring batch and has some questions regarding pause/resume. After reading spring batch documentation, there doesn't seem to have any built-in pause or resume functions. However, there is this use case i found from the main site:
http://docs.spring.io/spring-batch/2.0.x/cases/pause.html
There are no sample codes provided or is there any place I could find these samples?
In Spring batch, I understand there is a stop and restart function built-in. Could I use this as a form of pause and resume? Or there is another better way of doing it?
Stop/restart is essentially pause and resume. It allows you to programmatically stop a running job and pick up where it left off.
use job operator for this, it is the basic interface which provides functionalities such as stop , restart , getStatus
public interface JobOperator {
List<Long> getExecutions(long instanceId) throws NoSuchJobInstanceException;
List<Long> getJobInstances(String jobName, int start, int count)
throws NoSuchJobException;
Set<Long> getRunningExecutions(String jobName) throws NoSuchJobException;
String getParameters(long executionId) throws NoSuchJobExecutionException;
Long start(String jobName, String parameters)
throws NoSuchJobException, JobInstanceAlreadyExistsException;
Long restart(long executionId)
throws JobInstanceAlreadyCompleteException, NoSuchJobExecutionException,
NoSuchJobException, JobRestartException;
Long startNextInstance(String jobName)
throws NoSuchJobException, JobParametersNotFoundException, JobRestartException,
JobExecutionAlreadyRunningException, JobInstanceAlreadyCompleteException;
boolean stop(long executionId)
throws NoSuchJobExecutionException, JobExecutionNotRunningException;
String getSummary(long executionId) throws NoSuchJobExecutionException;
Map<Long, String> getStepExecutionSummaries(long executionId)
throws NoSuchJobExecutionException;
Set<String> getJobNames();
}
Here is an example for that
来源:https://stackoverflow.com/questions/18961698/spring-batch-pause-resume-vs-stop-restart