Wednesday, April 28, 2010

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

NOTE: I'm now blogging at http://jayvilalta.com/blog 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.

4 comments:

Rastko said...

Hi,
as I got, AdoStore have to be used only for persistence of the job states and fired triggers between two job executions. Correct me if I am wrong.

My questions is, could I use this store to load job configuration from. I would like to load job and trigger configuration as I am doing that from xml files persistence.

Is it possible with this provider or it is wrong address. Should I implement IPlugin interface ?

Thank you !

J said...

You can't add/load jobs from the ADO.Net job store. The store just keeps the scheduler's state. To add jobs you will need to use the xml plugin or write your own. You can also connect to a running scheduler via remoting and add jobs directly to the scheulder.

Unknown said...

where is part2

Unknown said...

where is scheduler configuration??