ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

What Is Quartz

by Chuck Cavaness, author of Programming Jakarta Struts, Second Edition

Quartz is an open source job-scheduling framework written entirely in Java and designed for use in both J2SE and J2EE applications. It offers great flexibility without sacrificing simplicity. You can create simple or complex schedules for executing any job. It includes features such as database support, clustering, plugins, prebuilt jobs for EJB, JavaMail and others, support for cron-like expressions, and many more.

In This Article:

  1. Job Scheduling Made Easy
  2. The History Behind Quartz
  3. Getting Your Hands on Quartz
  4. Inside the Quartz Architecture
  5. Jobs, Jobs, and More Jobs
  6. Job Management and Storage
  7. Available JobStores
  8. Jobs and Triggers
  9. Scheduling a Job
  10. Calling Your Jobs with the Scheduler
  11. Programmatic vs. Declarative Scheduling
  12. Stateful and Stateless Jobs
  13. Other Features of the Quartz Framework
  14. What's down the Road?
  15. Finding Out More About Quartz

Have you ever needed an application to perform a task that runs daily, every other Tuesday at 11:30 p.m., or maybe only on the last day of every month? A task that can run automatically, in a hands-off mode, and, if a serious error occurs during execution, the application will be so self aware that it declares a misfire and attempts to run itself again? Are you and your team programming in Java? If you've answered yes to any of these questions, then you ought to be using the Quartz Scheduler.

Job Scheduling Made Easy

Quartz is an open source job-scheduling framework written entirely in Java. Don't let the term job scheduling frighten you. While the Quartz framework is packed with many bells and whistles, in its simplest form, it's almost scary how easy it is to use.

Simply create a Java class that implements the org.quartz.Job interface. The Job interface contains a single method:

public void execute(JobExecutionContext context) 
     throws JobExecutionException;

Related Reading

Java Enterprise in a Nutshell
By Jim Farley, William Crawford

In your Job class, add some logic to the execute() method. Once you configure the Job class and set up the schedule, Quartz will take care of the rest. When the Scheduler determines it's time to notify your Job, the Quartz framework will call the execute() method on your Job class and allow it to do its thing. You don't have to report anything back to the Scheduler or call anything special. Just perform the tasks within the Job and end. If you configure your Job to be called again at a later time, the framework will take care of calling again at the right time.

If you've used other popular open source frameworks, like Apache Struts, you'll be comfortable with the design and components in Quartz. Even though the two open source projects solve completely different problems, there are enough similarities that everyday users of open source software will feel right at home. Quartz can be used within a stand- alone J2SE application, as an RMI server, within a web application, and even within a J2EE Application Server.

The History Behind Quartz

Quartz has been around for a while, although it has started to receive a lot of attention this year. It was created by James House and originally added as a SourceForge project in the spring of 2001. Over the next several years, a number of features and releases came, but it wasn't until the project was moved to a new site and became part of the OpenSymphony family of projects, that it really started to take off and receive the attention it deserves.

House still participates in much of the development work, with several part-time developers assisting him. The Quartz development team has been able to release several new versions this year, including the 1.5 release, which is currently in a candidate release stage.

Pages: 1, 2, 3, 4, 5

Next Pagearrow