|
Quartz Job Scheduling Framework(c) Building Open Source Enterprise Applications Authors: Cavaness Ch. Published year: Pages: 52/148 |
Using JobStoreTXThe first persistent JobStore that we discuss is called JobStoreTX . The "TX" in the name stands for "transaction." As we stated earlier, the JobStoreTX is designed to be used in an environment in which you want Quartz to manage the transactions. For example, if you are building a J2SE application and are not using an application server such as WebLogic or JBoss, JobStoreTX would be the right choice for a persistent JobStore . In the last section, you saw how easy it is to configure the RAMJobStore . We mentioned that one of the advantages to the RAMJobStore is its simple configuration. We've already discussed what has to be done to the database to get it ready; we now discuss what's needed to configure the Quartz application for a JDBC JobStore . Configuring the JobStoreTXTo tell the Quartz runtime environment that you want to use a JobStore other than the default RAMJobStore , you must configure several properties. It doesn't matter what order you do them in, but they all must be done before you run the application for the first time. Setting the JobStore PropertyTo inform the Scheduler that JobStoreTX should be used, you must add the following line to the quartz.properties file:
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX Be sure to remove the RAMJobStore line (if present) when switching to the JobStoreTX . Configuring the Driver DelegateIn the same way that the JDBC API relies on a JDBC driver designed specifically for a database platform, Quartz relies on a DriverDelegate to communicate with a given database. As the name implies, database calls from the Scheduler to the JobStore are delegated to a preconfigured DriverDelegate instance. The delegate is responsible for all communications with the JDBC driver and, thus, the database. All DriverDelegate classes extend the org.quartz.impl.jdbcjobstore.StdDriverDelegate class. The StdDriverDelegate has base functionality that all delegates, regardless of platform, can use. However, there is enough difference between some of these database platforms that a specialized delegate needs to be created for some platforms. Table 6.2 lists the specialized delegates. Table 6.2. You Must Configure One of the DriverDelegates Classes for Your Platform
After you determine which delegate you need based on your database platform, you need to add the following to the quartz.properties file:
org.quartz.jobStore.driverDelegateClass=<FQN of driver delegate class> As an example, if you are using MS SQL Server as your database platform, you would need to add the following to the properties file:
org.quartz.jobStore.driverDelegateClass=
org.quartz.impl.jdbcjobstore.MSSQLDelegate
Configuring the Database Table PrefixBack when we first discussed the database tables for Quartz, we mentioned that all the tables had the prefix QRTZ_ added to them. Under certain circumstances, you might need to create multiple sets of Quartz database tables. In that situation, you would need to change the prefix for each set. The prefixes for the table names are configured in the quartz.properties file using the property org.quartz.jobStore.tablePrefix . To change the prefix, just set the property to a different value:
org.quartz.jobStore.tablePrefix = SCHEDULER2_ Make sure the table names all start with this prefix.
Table 6.3 shows the set of properties that can be used to tune the JobStoreTX . Table 6.3. The Configuration Properties Available to Be Set for JobStoreTX
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Quartz Job Scheduling Framework(c) Building Open Source Enterprise Applications Authors: Cavaness Ch. Published year: Pages: 52/148 |
![]() Java Concurrency in Practice | ![]() Maven: The Definitive Guide | ![]() Java Generics and Collections | ![]() Spring in Action |
![]() Java Concurrency in Practice | ![]() Maven: The Definitive Guide |
![]() Java Generics and Collections | ![]() Spring in Action |