Reputation: 19
I want to know how the Ejb timer services calculates the timeout? Does it takes the system time and depending on it calculates the timeout or does it internally have mechanism to run a timer for itself. If it uses its own mechanish what is it and can we make some setting so that it can calculate the timeout depending on system Time?
I have searched for this information and didnt find any relevent information.I am currently using the TimerService in my code and programatically created the timers. But when I change the system time the timer does works as per that. Timeout occurs after the stepulated time when timer was created.
If I dont change the System time then the schedulers work perfectly fine..
Even if u can redirect me to any such information that will be gr8 help.
Any help will be really appriciated.
The code goes like this
ScheduleExpression everyDayAtTenTwenty = new ScheduleExpression();
TimerConfig timerConfig = new TimerConfig();
timerConfig.setPersistent(false);
timerConfig.setInfo("testTask");
everyDayAtTenTwenty.start(date).year("2011,2012").month("Jun").dayOfMonth("19").dayOfWeek("*").hour("16-23").minute("30"); timerConfig.setInfo("testTask : ");
timerKeeperBeanLocal.scheduleTimer(everyDayAtTenTwenty, timerConfig);
timerKeeperBeanLocal implementation
@Resource
private TimerService timerService;
Timer timer = this.timerService.createCalendarTimer(scheduleExpression, timerConfig);
Now here I want the scheduler to execute 19 June 2011 and 2012. Now the current Date is 19 June 2011 so today it executes and the same day I change the system date to 29 June 2011 along with proper time. In such case the scheduler doesnt work. The same can be tested with change is some hours. Do I need to do something else to work as per system time.
Thanks in advance.
Upvotes: 1
Views: 863
Reputation: 15250
The Ejb timer service uses the Java SE time APIs which in turn are based on system time. See
http://download.oracle.com/javase/6/docs/api/java/util/Date.html
And this is a quote from the EJB 3.1 specs:
While timer durations are expressed in millisecond units, this is because the millisecond is the unit of time granularity used by the APIs of the Java SE platform.
Upvotes: 1