I see no problems with it, especially since I wrote a "cron servlet" that
checks to make sure that other servlets I have deployed are up and running.
The servlet generates a table of URLs, last check time, and last response.
The information can be updated, and new entries added all through the
servlet. Unfortunately, it's used on our Intranet so I can't point you to a
URL.
My implementation uses two background threads for consumer/producer like
functionality. The producer thread wakes up every 30 seconds and looks to
see if it is a new minute (this is for "sleep drift"). If it is a new
minute, it looks through the "cron vector" for cron actions that are due
this minute. Any that are found are put into a work queue. The consumer
thread checks the queue every 10 seconds and then executes and removes any
cron action that is present.
I would post my code but I'm not sure if my work would like that very much.
Eric Fialkowski
Micron Internet Services
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Robb
Shecter
Sent: Friday, August 20, 1999 6:29 AM
To: [EMAIL PROTECTED]
Subject: Re: Using servlets for periodic background processes
Nic Ferrier wrote:
>
> Personally I think it's a bad idea.
>
Hi,
The idea sounds good to me. :) This servlet-cron service would simply
run in its own thread, and wakes up periodically. This could be
configured depending on the site's design. Maybe every 30 seconds
would be a good start. It would check if there's any tasks at that
point in time to be done, and when through go back to sleep.
In some informal checking, I've found that a sleeping thread uses no
detectable system resources.
Are there some negative aspects to this approach?
- Robb
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html