Job Storage in Quartz

Running Quartz with JobStoreTX

When you have completed the previous configuration steps, your application is ready to be started. Just as in all the previous examples, you still need a startup class that creates a Scheduler instance from the factory and calls the start() method. A class like the one listed in Listing 6.3 will suffice.

Listing 6.3. Simple Startup Class Called from the Command Line to Start the Scheduler

public class SchedulerMain {
 static Log logger = LogFactory.getLog(SchedulerMain.class);

 public static void main(String[] args) {
 SchedulerMain app = new SchedulerMain();
 app.startScheduler();
 }
 public void startScheduler() {
 try {
 // Create an instance of the Scheduler
 Scheduler scheduler =
 StdSchedulerFactory.getDefaultScheduler();

 logger.info("Scheduler starting up...");
 scheduler.start();

 } catch (SchedulerException ex) {
 logger.error(ex);
 }
 }
}

When you use the SchedulerMain class from Listing 6.3 to test the JobStoreTX configuration, you should get output similar to the following:

INFO [main] - Quartz Scheduler v.1.5.0 created.
INFO [main] - Using thread monitor-based data access locking (synchronization).
INFO [main] - Removed 0 Volatile Trigger(s).
INFO [main] - Removed 0 Volatile Job(s).
INFO [main] - JobStoreTX initialized.
INFO [main] - Quartz scheduler 'QuartzScheduler' initialized from default resource
file in Quartz package: 'quartz.properties'
INFO [main] - Quartz scheduler version: 1.5.0
INFO [main] - Scheduler starting up...
INFO [main] - Freed 0 triggers from 'acquired' / 'blocked' state.
INFO [main] - Recovering 0 jobs that were in-progress at the time of the last
shut-down.

INFO [main] - Recovery complete.
INFO [main] - Removed 0 'complete' triggers.
INFO [main] - Removed 0 stale fired job entries.
INFO [main] - Scheduler QuartzScheduler_$_NON_CLUSTERED started.

The log messages shown are using Log4j, so they might differ slightly from yours. A few things should be obvious from the output. First, no triggers or jobs were found in the database. This is a very important and sometimes confusing point. The database doesn't come loaded with any jobs or triggers: That's not possible because it wouldn't know which ones to load for you. This is something that you'll have to do yourself. You can get Scheduler information into the database in several ways.


Using Memory to Store Scheduler Information

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



Quartz Job Scheduling Framework(c) Building Open Source Enterprise Applications
Quartz Job Scheduling Framework: Building Open Source Enterprise Applications
ISBN: 0131886703
EAN: 2147483647
Year: N/A
Pages: 148

Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net