简体   繁体   中英

spring batch sleep between steps

How can I make a spring batch job sleep between executions if the next step is itself?

For example

<batch:step id="messages" next="messages">
.....
</batch:step>

I have tried using the parent="simpleJob" with the following configuration only to get unique key constraints. Not sure what I am missing.

<bean id="simpleJob" class="org.springframework.batch.core.job.SimpleJob" abstract="true">
    <property name="jobRepository" ref="jobRepository"/>
</bean>

<bean id="runScheduler" class="com.test.boa.scheduler.RunScheduler">
    <property name="dataSource" ref="dataSource"/>
</bean>

<task:scheduled-tasks>
    <task:scheduled ref="runScheduler" method="run" fixed-delay="500000"/>
</task:scheduled-tasks> 

The runScheduler is getting the next key but it seems like that doesn't get incremented upon step completion.

Any help would be appreciated.

You will need to set up listeners to intercept the before and after methods for your steps. http://docs.spring.io/spring-batch/trunk/reference/html/configureStep.html#interceptingStepExecution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM