开发者

Spring - problem with task scheduler

开发者 https://www.devze.com 2023-03-30 03:46 出处:网络
I have a strange problem with task scheduler. Here are three tested configurations of pingProducer in my appliacationContext.xml. The first and the second work. The third, which should produce the pin

I have a strange problem with task scheduler. Here are three tested configurations of pingProducer in my appliacationContext.xml. The first and the second work. The third, which should produce the ping every hour, doesn't - it produces the ping every minute. Am I missing something?

<!-- Ping scheduler - WORKS - every second -->
<task:scheduled-tasks>
    <task:scheduled ref="pingProducer" method="producePingRequest" cron="* * * * * ?" />
</task:scheduled-tasks>

<!-- Ping scheduler - WORKS - every minute -->
<task:scheduled-tasks>
    <task:scheduled ref="pingProducer开发者_StackOverflow中文版" method="producePingRequest" cron="0 * * * * ?" />
</task:scheduled-tasks>

<!-- Ping scheduler - DOES NOT WORK - every minute -->
<task:scheduled-tasks>
    <task:scheduled ref="pingProducer" method="producePingRequest" cron="0 0 * * * ?" />
</task:scheduled-tasks>


Change to:

<task:scheduled-tasks>
    <task:scheduled ref="pingProducer" method="producePingRequest" cron="50 0 * * * ?" />
</task:scheduled-tasks>

EDIT: once per hour, on the 50th second


<task:scheduled-tasks>
<task:scheduled ref="pingProducer" method="producePingRequest" cron="0 0 0/1 * * ?" />
</task:scheduled-tasks>

cron="0 0 0/1 * * ?" works because 0/x means run after every x hour from 0 o'clock.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号