tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darryl Miles <>
Subject Re: Starting background thread in contextInitialized ...
Date Mon, 04 Sep 2006 22:48:17 GMT
Andrés González wrote:
> Maybe a little OT, but: do you think it is a good "architecture" to
> have such a background thread processing those records periodically?.


For me I have many jobs running, some timed on a regular schedule, some 
timed and/or triggered from events (message passing), some jobs are 
setup to be persistable, some are created on demand.  But I don't want 
to run a full application server.  At a cost of a single long running 
thread to manage a cron like service.

> I mean, wouldn't it be preferable to create a separate process
> (another JVM) which would execute that thread?

Maybe if you are only running the job once every 12 hours, if you feel 
the cost of eating up a system thread in sleep state for most of the 
time is too much.  There are still classpath headaches and if you are 
doing anything more complex than direct JDBC calls (maybe with an ORM) 
just general configuration headaches to deal with by running another JVM 

> That way your design is more modular, and you can stop/start that
> daemon process easily, without interrupting the Tomcat.

There is nothing to stop you creating a simple servlet to control the 
job to enable/disable/kick-start.  There is nothing to stop you 
persisting that configuration setting.

Infact the above mentioned long running thread to manage things also 
takes care of error reporting and logging requirements amongst other 
manageability issues that will crop up if you are doing a more complex task.

The only issue with the approach comes when you are running more than 
one Tomcat instance (in a cluster) but if you are doing that then the 
features of an AS start to look beneficial.



To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message