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.
posted 7 years ago
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.