Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Batch:如何设置每个项目之间的时间间隔_Spring_Spring Batch_Sleep - Fatal编程技术网

Spring Batch:如何设置每个项目之间的时间间隔

Spring Batch:如何设置每个项目之间的时间间隔,spring,spring-batch,sleep,Spring,Spring Batch,Sleep,我必须在我的工作中设置每次ItemWriter执行之间的时间间隔,作为睡眠 我正在使用块任务 我的代码是: <job id="job" xmlns="http://www.springframework.org/schema/batch"> <step id="stepSendingEngine" parent="abstractStep"> <tasklet> <chunk reader="Reader"

我必须在我的工作中设置每次ItemWriter执行之间的时间间隔,作为睡眠

我正在使用块任务

我的代码是:

<job id="job" xmlns="http://www.springframework.org/schema/batch">
    <step id="stepSendingEngine" parent="abstractStep">
        <tasklet>
            <chunk reader="Reader" writer="Writer" commit-interval="1" retry-limit="3" skip-limit="100" >
                <retryable-exception-classes>
                    <include class="MyException"/>
                   </retryable-exception-classes>
                <skippable-exception-classes>
                    <include class="MyException"/>
                </skippable-exception-classes>
            </chunk>
            <listeners>
                <listener ref="MySkipListener" />
            </listeners>
        </tasklet>
    </step>
    <listeners>
        <listener ref="myListenerSupport" />
    </listeners>
</job>  

我认为最好解释一下为什么在编写器执行之间需要这种睡眠。对于Spring批处理,这似乎不是正确的方法


但是,此作业仍然由单个线程执行。您可以将睡眠放在任何位置(例如:在编写器的实现中)。

不仅仅是在使用ItemWriter帮助编写后放置Thread.sleep?延迟原因是什么?我的作业会为每个项目发送电子邮件。由于我的电子邮件提供商对发送限制存在问题,我需要等待一段时间间隔才能发送下一封电子邮件。