我使用的是tomcat 6.0版。我的要求是当tomcat启动时,我想启动一个 QuartzScheduler ,它会定期安排一些工作。我试图找出最好的方法来做到这一点。以下是我能想到的选项 -
对我来说,看起来第二种方法更好。第三个可能不是一个好主意,因为它显然不是由jconsole监视的MBean。我的目的是启动调度程序并在tomcat停止时停止它。 有没有更好更清洁的方法呢?
解决方案我会推荐第二种方法,使用一个只用于启动某些服务的Servlet,虽然常见的用法,对我来说似乎很苛刻。
看来quartz已经为这个目的提供了一个ServletContextListener: / p>
http:/ /quartz-scheduler/documentation/quartz-2.x/cookbook/ServletInitScheduler
和
www.quartz-scheduler/api/2.0.0 /
了解详情。
I am using tomcat version 6.0. My requirement is that when tomcat starts up, I would like to start a QuartzScheduler which will schedule some jobs at a regular interval. I am trying to figure out the best possible way to do it. Here are the options that I could think of -
To me, it looks like second approach is better. Third one might not be a good idea as it is clearly not a MBean to be monitored by jconsole or so. My purpose is to start the scheduler and stop it when tomcat stops. Is there any better and cleaner way to do this ?
解决方案I would recommend the second approach as well, using a Servlet that exists only to start up some service, while a common usage, seems hacky to me.
It appears that quartz already provides a ServletContextListener for this exact purpose:
quartz-scheduler/documentation/quartz-2.x/cookbook/ServletInitScheduler
and
www.quartz-scheduler/api/2.0.0/
for details.
更多推荐
在启动时集成tomcat和Quartz调度程序
发布评论