Spring - problem with task scheduler
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.
精彩评论