File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Invoking an EJB Timer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Invoking an EJB Timer" Watch "Invoking an EJB Timer" New topic
Author

Invoking an EJB Timer

Kumar Amit
Ranch Hand

Joined: Aug 13, 2001
Posts: 103
Hi Friends,
Ay idea how to invoke a EJBTimer (implemented as stateless session bean) daily? In other words how to schedule it?


SCJP, SCJD, SCEA
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9318
    
109

Does this help?

[My Blog] [JavaRanch Journal]
Kumar Amit
Ranch Hand

Joined: Aug 13, 2001
Posts: 103
Jaikiran Pai wrote:Does this help?

Thanks Jai and nice article. However this article describes auto timers in ejb 3.1. Since i am using ejb 3.0 for this assignment, i have to create auto timer using it. Any idea how to do with ejb 3.0.

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9318
    
109

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
Ranch Hand

Joined: Aug 13, 2001
Posts: 103
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.
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?
Mario Kerk
Greenhorn

Joined: Jun 13, 2005
Posts: 10

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
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11279
    
  59

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.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Mario Kerk
Greenhorn

Joined: Jun 13, 2005
Posts: 10

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.


Hi Andrew,
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

 
jQuery in Action, 2nd edition
 
subject: Invoking an EJB Timer
 
Similar Threads
Args in Netbeans
thanks!!! another SCJP born~
Clock problem
Ant and Cactus - classpath issues
http-method not specified