Guys,
Why is it that people seem to want to make everything a servlet? What about this cron class is servlet like? Is it getting invoked by a http request? When I wrote our cron-like utility (very basic replacement that handles what we need, doesn't have all the bells and whistles of cron, runs on all platforms, controlled via our database not crontab files) I wrote it as a Java application.
Just curious as to what I'm missing, as I tend to put everything that is not about handling requests from the user and building HTML responses in something other than the servlets (clean separation of the model and the view in my mind).
Thanks,
Brian
-----Original Message-----
From: Tim Panton [mailto:[EMAIL PROTECTED]]
Sent: Saturday, August 21, 1999 4:52 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
I don't think a generic cron replacement servlet is a good idea,
Cron has lots of nice properties that are hard to do in the servlet
environment like :
Persistence across reboots/crashes
correct actions over DST changes (allegedly)
reliable one-shot actions
run as less (or more) privileged user
If however you have a bit of servlet (or webapp) related periodic
activity,
then it is fine to code up a thread to be spun off from a servlet,
but be very aware of the servlet lifecycle as it is implemented in your
web server/engine.
Here are a couple of things that might trip you up:
1) In some engines servlets are not loaded until the first use,
so your cron-servlet may never be loaded unless you take special steps.
2) Some engines will destroy a servlet that's been idle for a long
time, and then subsequently start a new instance. Your background thread
however may still have a reference to the old servlet, and update the
state
of the 'destroyed' one.
3) Some engines have multiple VM's running, be sure that the cron
servlet is in the one you want, i.e. the JVM serving https: servlets may
not
be the same as the one serving http: servlets.
None of these issue are insurmountable, but they sure can slow you down,
as I've discovered.
T.
___________________________________________________________________________
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
