Manually firing Quartz scheduler jobs

Exactly what the title says, this snippet will fire all job for all schedulers registered.

// Get our scheduler factory
StdSchedulerFactory schedulerFactory = new StdSchedulerFactory();
Collection<Scheduler> schedulers=schedulerFactory.getAllSchedulers();
for(Scheduler scheduler:schedulers){
	System.out.println("scheduler "+scheduler.getSchedulerName());
	String[] groups=scheduler.getJobGroupNames();
	for(String jobGroup:groups){
		System.out.println("   ** GROUP="+jobGroup);
		String[] jobNames=scheduler.getJobNames(jobGroup);
		for(String jobName:jobNames){
			System.out.println("    ** jobName="+jobName);
			//Fire actuall job
			 scheduler.triggerJob(jobName,  jobGroup);
		}
	}
}

Leave a Comment

Your email address will not be published. Required fields are marked *