Created
July 16, 2012 07:16
-
-
Save rtrcolin/3121315 to your computer and use it in GitHub Desktop.
Quartz Managed by Dropwizard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class QuartzManager implements Managed { | |
private Scheduler scheduler; | |
private QuartzSchedulerMonitor schedulerMonitor; | |
private QuartzJobMonitor jobMonitor; | |
public QuartzManager(SchedulerFactory sf) throws SchedulerException { | |
scheduler = sf.getScheduler(); | |
schedulerMonitor = new QuartzSchedulerMonitor(); // Implements SchedulerListener | |
scheduler.getListenerManager().addSchedulerListener(schedulerMonitor); | |
jobMonitor = new QuartzJobMonitor(); // Implements JobListener | |
} | |
@Override | |
public void start() throws Exception { | |
scheduler.start(); | |
// Make our Job listener cover all scheduled jobs | |
scheduler.getListenerManager().addJobListener(jobMonitor, EverythingMatcher.allJobs()); | |
} | |
@Override | |
public void stop() throws Exception { | |
scheduler.getListenerManager().removeJobListener(jobMonitor.getName()); | |
scheduler.shutdown(true); | |
} | |
public boolean isHealthy(){ | |
return schedulerMonitor.isHealthy() && jobMonitor.isHealthy(); | |
} | |
/* | |
A rudimentary example to get the state of the jobs and scheduler. | |
*/ | |
public String getState() { | |
return "Scheduler: " + schedulerMonitor.getState() + " Jobs:" + jobMonitor.getState(); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where is QuartzJobMonitor.java and QuartzSchedulerMonitor.java ?