Skip to main content

TimerService rescheduling periodic timer

2 replies [Last post]
Joined: 2007-11-27


I have a timer bean that performs some tasks. However, I noticed if it can not execute at the given time, I notice during next application server start, it will try to reschedule.

I create it with timerService.createTimer(0, interval, timerName);

where 0 is initial duration, and interval is interval.

The api documentation talks about rescheduling on method createTimer(startdate, interval, timerName)

but not on createTimer(initial, interval, timerName) like I used. why is it rescheduling, what can I do to avoid missed rescheduling.

Best Regards,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2005-05-20

The spec requires that the container call ejbTimeout at least once for any periodic timer that
missed at least one delivery due to the server being shutdown. That's part of the persistent
timer delivery guarantee.

Are you looking for more of a transient timer whose lifetime is only
tied to the JVM in which it was created?

Joined: 2007-11-27

yes, I like it a non persistent timer. when the application is undeployed, it should shut off as well. I am doing some statistics measurements over some data,and I also need to be able to access EJB beans in my application.

I have looked at quartz, but it was too complicated and not EJB3 friendly.

Maybe I could do something within the timer, that if it is delayed (I dont know how that can be measured, but..) that does not execute its payload.

I also tried doing a background thread in a singleton instance. bad idea. application is undeployed, but thread is still alive.