Starting Quartz Server using Spring

I have been using quartz to do some batch scheduling on a project. I found that most of the Spring Quartz classes do not really work that well with the 1.6 version of Quartz.

I did find a easy way to start the Quartz scheduler using a simple spring call.

I created a ~SimpleSchedule class in java that will create a simple scheduler.

public class SimpleSchedule
{
  private static Log log = LogFactory.getLog(SimpleSchedule.class);
  
  public SimpleSchedule()
  {
    try
    {
      Scheduler scheduler = this.createScheduler();
      
      // Start the Scheduler running
      scheduler.start();
      
      log.info( "Scheduler start at " + new Date());
    } catch (SchedulerException ex)
    {
      log.error(ex);
    }
  }

  public Scheduler createScheduler() throws SchedulerException
  {
    return StdSchedulerFactory.getDefaultScheduler();
  }
}

To get this scheduler to start at load, all I have to do is initialize the bean in spring, and the scheduler is created and loads the default quartz_jobs.xml.

<bean class="edu.unc.its.as.affiliate.quartz.SimpleSchedule"/>

Posted on Apr 22, 2008 by Mike Jennings in Java | 0 Comments | Permalink



Post a Comment:
Comments are closed for this entry.