Besides starting the Scheduler, you might need to perform a few other operations on the Scheduler during your application's lifetime. These Scheduler operations include querying, putting the Scheduler in standby mode, resuming, and stopping. For many situations, when a Scheduler is started, you don't need to do anything except let it run. In certain circumstances, you might need to temporarily halt the Scheduler using the standby mode.
Starting the Scheduler
Starting the Scheduler couldn't be more straightforward. When you have an instance of a Scheduler that has been properly initialized and your jobs and triggers have been registered, simply call the start() method:
//Create an instance of the Scheduler Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); //Start the scheduler scheduler.start();
When the start() method is called, the Scheduler starts looking for jobs that need to be executed. You use the start() method when you have a new Scheduler instance and when the Scheduler has been placed into standby mode. After shutdown() has been called, you can no longer call start() on that Scheduler instance.
Standby Mode
Putting the Scheduler in standby mode causes the Scheduler to temporarily stop looking for jobs to execute. As an example, suppose your Scheduler gets its job information from a database and you need to restart the database. You could either restart Scheduler when the database is back online or just put the Scheduler in standby mode. You can put a Scheduler in standby mode by calling the standby() method:
public void standby() throws SchedulerException;
In standby mode, the Scheduler does not attempt to execute jobs because the thread that searches for jobs that need executing is paused.
Stopping the Scheduler
You can use two versions of the shutdown() method to stop the Scheduler:
public void shutdown(boolean waitForJobsToComplete) throws SchedulerException; public void shutdown() throws SchedulerException;
The only difference between these two methods is that one version takes a Boolean argument that doesn't let the Scheduler stop until all currently executing jobs have finished executing. The shutdown() method without the argument is similar to calling shutdown(false).
Managing Jobs |
Scheduling in the Enterprise
Getting Started with Quartz
Hello, Quartz
Scheduling Jobs
Cron Triggers and More
JobStores and Persistence
Implementing Quartz Listeners
Using Quartz Plug-Ins
Using Quartz Remotely
Using Quartz with J2EE
Clustering Quartz
Quartz Cookbook
Quartz and Web Applications
Using Quartz with Workflow
Appendix A. Quartz Configuration Reference