spring batch一次只运行一个作业实例并创建它的队列

时间:2015-06-08 09:31:52

标签: spring-batch spring-integration

一次只在作业实例上运行,这可以:Spring batch restrict single instance of job only

public class jobMailListener implements JobExecutionListener {

// active JobExecution, used as a lock.
private JobExecution _active;


public void beforeJob(JobExecution jobExecution) {
    // create a lock
    synchronized (jobExecution) {
        if (_active != null && _active.isRunning()) {
             //***************************//
            // Here create/storage in queue it up ? 
            //****************************//
            jobExecution.stop();
        } else {
            _active = jobExecution;
        }
    }
}

public void afterJob(JobExecution jobExecution) {
    // release the lock
    synchronized (jobExecution) {
        if (jobExecution == _active) {
            _active = null;
        }
    }
}

}

<batch:job id="envoiMail" restartable="true">
    <batch:listeners><batch:listener ref="jobMailListener"/>
    <batch:step id="prepareData">...

我不会停止工作但是会创建一个队列。

可以用弹簧集成吗?

我想http://incomplete-code.blogspot.fr/2013/03/spring-batch-running-only-one-job.html#comment-form 但它不起作用。

0 个答案:

没有答案
相关问题