Using Persistent JobStores

In many ways, JobStores that use memory for storage and those that use some form of long-term persistence share similar traits. This shouldn't be that surprising because they both serve the same purpose.

As with RAMJobStore, persistent JobStores have both advantages and disadvantages. You should be careful to understand the pros and cons before choosing a persistent JobStore. This section explains the differences and the circumstances under which you would want to use a persistent JobStore.

Currently, Quartz provides two types of persistent JobStores, each one unique in its persistence mechanism.

Persistent JobStores = JDBC + Relational Database

Although several different persistence mechanisms can used to persist Scheduler information for Quartz, Quartz relies on a relational database-management system (RDMS) for persistent storage. If you want to use something other than a database for persistent storage, you must build it yourself by implementing the JobStore interface. Suppose that you wanted to use the file system for persistent storage. You could create a class that implements the JobStore interface. In this chapter, when we say "persistent," we are implicitly talking about using JDBC to persist Scheduler state into the database.

All the persistent JobStores that ship with Quartz extend the org.quartz.impl.jdbcjobstore.JobStoreSupport class.

The JobStoreSupport Class

The JobStoreSupport class is abstract and implements the JobStore interface, discussed earlier in the chapter. It provides base functionality for all JDBC-based JobStores. Figure 6.1 shows the type hierarchy for JobStores.

Figure 6.1. The JobStore type hierarchy

As Figure 6.1 illustrates, JobStoreSupport implements the JobStore interface and acts as a base class for the two concrete persistent JobStores that Quartz offers.

JobStoreSupport Should Have Been Named JDBCJobStoreSupport

A better name for this class would have been JDBCJobStoreSupport because this class is specifically designed to work with JDBC-based storage solutions. However, the name doesn't detract from the functionality that it provides for persistent JobStores.

Because the JobStoreSupport class is abstract, Quartz offers two different types of concrete persistent JobStores, each one designed for a specific database environment and configuration:

Both persistent JobStores are discussed shortly. For now, let's talk about the database that is required for both versions.

Категории