-
1. Re: How do you view Timers in the EJB3 timer service
wdfink Aug 22, 2012 1:51 PM (in response to foutjo)If you want to see the timers of one specific Bean you have to have the dumpTimers() method in that Bean.
Each Bean will have its own timers.
-
2. Re: How do you view Timers in the EJB3 timer service
foutjo Aug 22, 2012 2:19 PM (in response to wdfink)Thanks Wolf,
Is there a way for the bean to have a method that would pass the timers to another program?
TimerBean
public Collection<Timer> getAllTimers()
{
return timerService.getTimers();
}
** I tried the above but I'm getting serializable error.
Any ideas?
Thanks.
-
3. Re: How do you view Timers in the EJB3 timer service
cfang Aug 22, 2012 3:04 PM (in response to foutjo)Have you tried query/parse the underlying timer storage? Of course its format or structure may change any time but that seems to be the quickest way to get what you want.
in EJB 3.2 there will be a TimerService.getAllTimers() to return all timers for the current ejb jar, but still won't give you all timers in the server instance.
In your code above, you could return a string representation t.getInfo(), or TimerHandler. I suppose you only need timers for view only purpose, without invoking any timer operations on them.
-
4. Re: How do you view Timers in the EJB3 timer service
wdfink Aug 23, 2012 1:59 AM (in response to foutjo)A Timer is a server internal Object that should not be given to an external program, also it is not usable for this. This is the reason for Timer not implement Serializable.
If you only want to have an overview you might collect a string representation with some properties (i.e. next timeout, persistent, recurring, owner, ...).
Until EJB3.2 you have to implement a Bean wich calls all known timers in your app, starting with 3.2 you might use the approach Cheng mentionend.
-
5. Re: How do you view Timers in the EJB3 timer service
foutjo Aug 23, 2012 8:21 AM (in response to wdfink)Thanks Cheng and Wolf.
Your suggestions have been a big help.
-
6. Re: How do you view Timers in the EJB3 timer service
jaikiran Aug 24, 2012 12:44 AM (in response to foutjo)As an FYI - We do have plans to make the EJB timers more "manageable" in AS 7.2.x version.
-
7. Re: How do you view Timers in the EJB3 timer service
foutjo Aug 24, 2012 8:04 AM (in response to jaikiran)That sounds even better Jaikiran.
I do have a couple of more questions regarding timers.
1. If the date and time defined in a scheduleExpression of a Timer are in the past will they
be processed once the application server is started?
2. If the Timer is not explicitly canceled with the .cancel() method will the Timer continually
try and get processed if the date and time are in the past?
Thanks again for all of your help.
-
8. Re: How do you view Timers in the EJB3 timer service
jaikiran Aug 24, 2012 8:13 AM (in response to foutjo)This Is what the EJB spec says:
Timers are persistent objects (unless explicitly created as non-persistent timers). In the event of a container crash or container shutdown, any single-event persistent timers that have expired during the intervening time before container restart must cause the corresponding timeout callback method to be invoked upon restart. Any interval persistent timers or schedule based persistent timers that have expired during the intervening time must cause the corresponding timeout callback method to be invoked at least once upon restart.
-
9. Re: How do you view Timers in the EJB3 timer service
wdfink Aug 24, 2012 8:25 AM (in response to foutjo)If yo add the timer via API persistent will call the timeout-method for each missing event, a non-persistent timer does not exist after server (re)start.
If you have a @Schedule annotated one a persistent timer behaviour is the same as above, a non-persistent will call the timeout-method for the next schedule, missed times are lost.
-
10. Re: How do you view Timers in the EJB3 timer service
foutjo Aug 24, 2012 9:11 AM (in response to wdfink)Thanks again Jaikiran and Wolf.