Hi,
I am trying to use spring (v 3.0.1.RELEASE-A) based scheduler for a scheduler application. I just started using it with a cron expression. However I find that only sometimes the job is called twice.
My spring configuration is
To see how the job is getting called I have put few debug sysouts, the MyScheduledJobProcessor class looks likeCode:<task:scheduled-tasks scheduler="jobScheduler"> <task:scheduled ref="jobProcessor" method="process" cron="0 0/1 * * * *"/> </task:scheduled-tasks> <task:scheduler id="jobScheduler" pool-size="1"/> <bean id="jobProcessor" class="MyScheduledJobProcessor"/>
The output looks likeCode:public class MyScheduledJobProcessor implements JobProcessor{ public void process() { System.out.println("ScheduledJobProcessor called at " + new Date() + " and "+ Thread.currentThread().getId()); } }
ScheduledJobProcessor called at Fri Dec 09 03:59:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 03:59:59 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:00:00 EST 2011 and 7 // Called twice here
ScheduledJobProcessor called at Fri Dec 09 04:01:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:02:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:03:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:03:59 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:04:00 EST 2011 and 7 // Called twice here
ScheduledJobProcessor called at Fri Dec 09 04:05:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:06:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:06:59 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:07:00 EST 2011 and 7 // Called twice here
ScheduledJobProcessor called at Fri Dec 09 04:08:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:09:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:10:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:11:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:11:59 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:12:00 EST 2011 and 7 // Called twice here
ScheduledJobProcessor called at Fri Dec 09 04:13:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:14:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:15:00 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:15:59 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:17:00 EST 2011 and 7 // Called twice here
ScheduledJobProcessor called at Fri Dec 09 04:17:59 EST 2011 and 7
ScheduledJobProcessor called at Fri Dec 09 04:18:00 EST 2011 and 7
I am not able to figure out what I did wrong. It's a simple cron job which is supposed to run every minute. Moreover there is no pattern in calling the job twice.
Any help is appreciated!
Shashi


Reply With Quote