1

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.

0

1 Answer 1

1

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.

3
  • My concern is that once the timer is created and after that if the system date time is changed does the same is reflected in already created timers. Thanks for thee reply :)
    – khushi
    Nov 8, 2011 at 11:31
  • Yes, changing the system date will influence the currently created timers. Nov 8, 2011 at 15:09
  • In my case it is not working in that way with EJB 3.1 Timer Service
    – khushi
    Nov 9, 2011 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.