The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: Schedule method executions

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 4 - Last Post: Sep 8, 2006 8:47 AM by: demiant
demiant

Posts: 68
Schedule method executions
Posted: Sep 8, 2006 7:03 AM
  Click to reply to this thread Reply

Hi,

Assuming I need some methods to be executed during specific times or per constant interval (for example a process that go through all orders within the system and make sure all of them were paid in time),

is it possible to schedule these method executions through GF? or I have to use an external scheduler such as http://www.opensymphony.com/quartz/

Thanks a lot,

Demian

ksak

Posts: 455
Re: Schedule method executions
Posted: Sep 8, 2006 8:01 AM   in response to: demiant
  Click to reply to this thread Reply

HI Demian,

You can do this portably via the EJB Timer Service, which allows you
to schedule either one-time or periodic event notifications that are
delivered to either a stateless session bean or message-driven bean.
Chapter 22 in the Java EE 5 Tutorial that can get you started :

http://java.sun.com/javaee/5/docs/tutorial/doc/

--ken

demiant

Posts: 68
Re: Schedule method executions
Posted: Sep 8, 2006 8:24 AM   in response to: ksak
  Click to reply to this thread Reply

Hey,

I already have seen this chapter and read it, but my problem is that I cant find a way to create a timer automatically when the application is deployed,

I dont want any client to create the timer explicitly


thanks!

sbalmos

Posts: 56
Re: Schedule method executions
Posted: Sep 8, 2006 8:41 AM   in response to: demiant
  Click to reply to this thread Reply

The hack that I use, and seem to see in popular use, is to have a servlet that is loaded on deploy and is not bound to any URL, to prevent access. Then in the servlet's init() method, you call the init methods of each EJB that needs to be added to the Timer service.

--Scott

demiant

Posts: 68
Re: Schedule method executions
Posted: Sep 8, 2006 8:47 AM   in response to: sbalmos
  Click to reply to this thread Reply

heh, didnt think about this,

thanks !




 XML java.net RSS