Wednesday, April 28, 2010

Configuring Quartz.Net with an ADO.Net Job Store (AdoJobStore) – Part 2

NOTE: I'm now blogging at and not updating this blog anymore. For information on the latest version of Quartz.Net, visit me there.

In Part 1 we set up our database so that we could use it as a job store for Quartz.Net. Now, we need to set up our scheduler job store properties to use said database. Here are the most common properties and values that need to be set in order to get the scheduler to use the database as its job store:
Property Value
quartz.jobStore.type Quartz.Impl.AdoJobStore.JobStoreTX, Quartz
quartz.jobStore.dataSource default
quartz.jobStore.tablePrefix QRTZ_
quartz.jobStore.clustered true
quartz.jobStore.lockHandler.type Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz
quartz.jobStore.driverDelegateType Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz
quartz.dataSource.default.connectionString Server=localhost;Database=youeverseethefly;Uid=brundle;Pwd=fly;
quartz.dataSource.default.provider SqlServer-20
quartz.jobStore.useProperties true
You can set these properties in your config file, but the specific file will depend on whether you are using the default configuration file or something else. If you are using the default (distribution) settings, these properties will go in your quartz.config file.
That’s all there is to setting up an AdoJobStore. Start up your service and take a look at the event log to see if the scheduler started up correctly.

Configuring Quartz.Net with an ADO.Net Job Store (AdoJobStore) – Part 1

NOTE: I'm now blogging at and not updating this blog anymore. For information on the latest version of Quartz.Net, visit me there.

Quartz.Net stores all of its job related configuration in an aptly named JobStore. There are two different kinds of job stores available out of the box: RAMJobStore and AdoJobStore. By default, Quartz.Net uses a RAMJobstore. The RAMJobStore is extremely simple to configure, but it is a volatile store, so all job configuration is lost whenever the scheduler is restarted.
If you need your job configuration to be persisted between scheduler restarts and/or you are going to be running more than one instance of the scheduler in a cluster, you will need to use the AdoJobStore. This job store uses ADO.Net to persist all the job configuration information in a database. The following table shows the most common database providers that are supported, as well the name of the Quartz.Net database provider to use. The full list of providers can be found in lesson 9 of the Quartz.Net tutorial.
Database Provider Quartz.Net Provider Name
SQL Server driver for .NET Framework 2.0 SqlServer-20
Oracle Driver (by Microsoft) OracleClient-20
MySQL Connector/:NET v. 5.1 (.NET 2.0) MySql-51
SQLite ADO.NET 2.0 Provider v. 1.0.56 (.NET 2.0) SQLite-10
This post will focus on configuring the job store for SQL Server. If you’d like to see similar posts for the other databases, please let me know in the comments.
First, let’s take a look at the steps you will need to follow to start using an ADO.Net job store:
  1. Set up the database by creating the tables that Quartz.Net will use.
  2. Configure the scheduler to use the database server that you just set up.
It’s not that complicated, is it?

Step 1: Setting up the database

First, you will need to locate the setup script for your database server. In our case, we will use the SQL Server setup script. All setup scripts are located under the database/tables folder of the Quartz.Net distribution. The script we are looking for is called tables_sqlServer.sql. Open the script in a text editor and update the USE [enter_db_name_here] statement to point to whatever database you want to use. Once you’ve changed the database name in the script, you can go ahead and execute it. This script will create several tables in the database you set in the script. All of the Quartz.Net tables will be prefixed by QRTZ_ . Once you’ve successfully created all the tables, it’s time to configure the scheduler.
In Part 2 we will cover configuration of the scheduler.