Thanks Jai. I was talking about client code to invoke the method to trigger the timer. What is the best way to invoke the method on the bean which will create/trigger the timer (timerService.createTimer() etc). Should I use Startup servlet that will invoke this startTimer() method on the bean or something else?
Jaikiran Pai wrote:EJB3.0 did not have a feature of "auto timers". You had to programatically create the timers via the javax.ejb.TimerService. Here's an example. The client code would have to invoke that method on the bean for the timer to be started and triggered.
Kumar Amit wrote:I was talking about client code to invoke the method to trigger the timer. What is the best way to invoke the method on the bean which will create/trigger the timer (timerService.createTimer() etc). Should I use Startup servlet that will invoke this startTimer() method on the bean or something else?
Here's another example that uses a ServletContextListener to start up a Timer.
However, I also recommend reading this thread as well, because it mentions some of the common "gotchas" to keep in mind when using EJB 3.0 timers.
Andrew Monkhouse wrote:For the SCEA/OCMJEA exams, you do not need to go so deeply into the APIs. You might want to take a higher level view.
I'm a bit confused by your reply.
Do you mean that it in a SCEA assignment it would not be important to show how a recurring Timer would be initially scheduled as part of the design OR that we should not worry too much about known shortcomings of this feature (such as the ones mentioned in the other thread I referenced)?
Btw, I should note that in real life projects I have only used quartz, because I've read too many posts on the tricks required to set up Timers properly in clusters, but mostly because quartz always fit the bill better in the end.
Nevertheless, for my SCEA assignment I am considering of suggesting the use of a Timer for a simple polling job to avoid having to introduce an external library in the design. But because even my SCEA project is supposed to be deployable in a cluster, I can't help but wonder if I would need to demonstrate that I'm aware of all this... But then again I'm probably over-thinking