Friday, January 17, 2014

Best Java Enterprise Scheduler (Quartz) with auto-start and stop on deployment

The best Java Enterprise scheduler I've used so far is quartz.

Its very proper and comes with all the needed class modules. And definitely have seen it being used professionally to extremes.


How to



Note* - Use log4j classes

Auto Start Stop

This is done by adding custom lines to ContextListener. By simply deploying and undeploying packages quartz can be start and stopped.

public class Config implements ServletContextListener {

    public void contextInitialized(ServletContextEvent event) {
        ***Code to initialize quartz thread pool***
    }

    public void contextDestroyed(ServletContextEvent event) {
        ***Code to stop quartz thread pool***

    }

}
and register it as a <listener> in web.xml.
<listener>
    <listener-class>com.example.Config</listener-class>
</listener>

No comments:

Post a Comment