Re: Running schduled jobs

2009-07-11 Thread Michael Echerer
Ravi Sharma wrote:
 Hi All,
 I need to run some threads at particular time during the day, does Tomcat
 provide any such facility? If not then whats the other best way to go for
 it.
   
Well for scheduled jobs Quartz is a common tool, if java.util.Timer is
not sufficient. Certainly not Tomcat-related however as only full JEE
containers have buildt-in timer support.
 Basically i recalculate my site's visitor data every 30 minute and keep in
 cahce and then display to users, 30 minute delay for my data is fine but
 atleast i dont need to run queries to find those data for each request. Now
 every 30 minute i want to run those query and update the cache. How can i
 achive it.?
   
Trying to use java.util.Timer or Quartz for this particular problem
appears architecturally questionable however. Preferably you would have
an O/R mapper like Hibernate an rely on some second level cache like
EHCache to do thus common DB query caching stuff via configuration
instead of implementing such common tasks on your own. Maybe you want to
rethink that from an architectural point of view to get things right for
all DB queries, unless the problem described is very focused on that
particular caching problem.
Sometimes OSCache's JSP-based caching can also be a valid solution, if
all you want to do is to cache some view results:
http://www.opensymphony.com/oscache/wiki/JSP%20Tags.html
 Thanks,
 Ravi.
   
Cheers,
Michael


-- 

TNG Technology Consulting GmbH, Betastr. 13a, D-85774 Unterföhring
Geschäftsführer: Henrik Klagges, Eike Reinel, Christoph Stock
Amtsgericht München, HRB 135082


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Running schduled jobs

2009-07-11 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Ravi,

On 7/10/2009 10:32 PM, Ravi Sharma wrote:
 I need to run some threads at particular time during the day, does Tomcat
 provide any such facility? If not then whats the other best way to go for
 it.

Other than webapp-oriented options, I'd like to remind you (and others)
that any decent server OS has the ability to schedule jobs outside of
any request-oriented server like Tomcat.

Consider using cron on *NIX or the Task Scheduler on Windows or
whatever. You can still write your code in Java is you want.

I just find that running scheduled jobs from a webapp to be
inappropriate at best and inconvenient and unreliable at worst.
Schedulers such as cron have the ability to run jobs at strange
intervals (such as every day, but only on weekdays), to run jobs missed
during system downtime, etc.

 Basically i recalculate my site's visitor data every 30 minute and keep in
 cahce and then display to users, 30 minute delay for my data is fine but
 atleast i dont need to run queries to find those data for each request. Now
 every 30 minute i want to run those query and update the cache. How can i
 achive it.?

You could write a component that updates visitor data on demand at
intervals instead of proactively scheduling it: it's just an expiring
cache. Your component returns the cached data unless some time limit has
been exceeded, at which point all clients wait while the new set of
visitor data is loaded into the cache.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkpY9d4ACgkQ9CaO5/Lv0PC/vACgiHAiV9InIcNcHtIbgszTZ6qm
ZY4An26rZiSGInknLAJjzCToU9WqTf0L
=/oX1
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Running schduled jobs

2009-07-10 Thread Ravi Sharma
Hi All,
I need to run some threads at particular time during the day, does Tomcat
provide any such facility? If not then whats the other best way to go for
it.

Basically i recalculate my site's visitor data every 30 minute and keep in
cahce and then display to users, 30 minute delay for my data is fine but
atleast i dont need to run queries to find those data for each request. Now
every 30 minute i want to run those query and update the cache. How can i
achive it.?

Thanks,
Ravi.


RE: Running schduled jobs

2009-07-10 Thread Caldarale, Charles R
 From: Ravi Sharma [mailto:ping2r...@gmail.com]
 Subject: Running schduled jobs
 
 I need to run some threads at particular time during the day,
 does Tomcat provide any such facility?

Tomcat doesn't, but Java does: java.util.Timer.  Just make sure to cancel() the 
timer when your webapp is being stopped.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org