wood burning stoves*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Doubt on TimerService API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Doubt on TimerService API" Watch "Doubt on TimerService API" New topic
Author

Doubt on TimerService API

prashant k. gupta
Ranch Hand

Joined: May 15, 2008
Posts: 62
Hi All,

Can we use timer service in StatefulSession bean? And for every scheduled task for timerservice , do client need to invoke the method? If yes then how will it work if scheduled time has come for particular task and client has not invoked the particular method?

Kindly explain this.
Jim Janssens
Ranch Hand

Joined: Sep 24, 2004
Posts: 210
Timers can only be used from SLSB or MDB's, not from SFSB. This makes sense if you think about it; both SLSB and MDB have stateless behaviour. If you would make a timer that calls back within 2 days, it will just fire up a method ready instance from the SLSB pool, it doesn't matter which one since there is no state retention anyways.

If you would be allowed to do this on a SFSB, chances are (very) high that the SFSB in questions (the instance from which you created the timer callback) has already been removed, so the state is already gone. Point is that you cannot count on the state of the given SFSB being there when the timeout has expires, therefore (and probably for other reasons as well) you cannot create a timer callback from a SFSB.

For your second part; yes, you must invoke the timer service method for each callback you want to make. You SLSB can at most have one 'timeout' method that will be called by the timer server once the timeout expires. If you register multiple timers for the same bean, the timeout method will be invoked multiple times.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt on TimerService API
 
Similar Threads
Timers
Understanding of the ScheduledFuture Interface
Timer Service Accuracy
Timer
Invocation of a TimerService