Skip to content

Instantly share code, notes, and snippets.

@rtrcolin
Created July 16, 2012 14:56
Show Gist options
  • Save rtrcolin/3123161 to your computer and use it in GitHub Desktop.
Save rtrcolin/3123161 to your computer and use it in GitHub Desktop.
Quartz Health Check
import com.yammer.metrics.core.HealthCheck;
import org.quartz.SchedulerException;
...
public class QuartzHealthCheck extends HealthCheck {
private QuartzManager quartzManager;
public QuartzSchedulerHealthCheck(QuartzManager qm) throws SchedulerException {
super("Quartz Scheduler Health Check");
this.quartzManager = qm;
}
/**
* Checks the state of the Quartz Scheduler and all scheduled Quartz jobs
* @return Result Healthy if the scheduler and all of it's jobs are running withing acceptable parameters
* @throws Exception if unable to check the state of the scheduler or its jobs
*/
@Override
protected Result check() throws Exception {
// The Quartz is currently in an error state
if (!quartzManager.isHealthy())
return Result.unhealthy(quartzManager.getState());
else
return Result.healthy();
}
}
@wulinjie122
Copy link

i found it, thank you.

@nalikaa
Copy link

nalikaa commented Sep 8, 2022

@rtrcolin @wulinjie122 Can you please point me to the source code for QuartzManager.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment