Quartz.Net Job Storage Query

you can use AdoJobStore.
Quartz.net will use a set of tables with prefix QRTZ_ (you can change it if you want) in your database to stored jobs, triggers and status of these objects.
I guess you want to have a table in your DB where you’re going to keep extended information about your schedules, right?
You won’t access Quartz.net table directly cause you will use the APIs provided by Quartz.net.

The process to create a job detail and trigger is straightforward and described very well in the tutorials.

To configure your app to use the AdoJobStore you have to specify few informations in your app.config file.
Here is an example:

  <quartz>
    <add key="quartz.scheduler.instanceName" value="myApp" />
    <add key="quartz.scheduler.instanceId" value="MyApp" />
    <!-- Configure Thread Pool -->
    <add key="quartz.threadPool.type" 
                  value="Quartz.Simpl.SimpleThreadPool, Quartz" />
    <add key="quartz.threadPool.threadCount" value="10" />
    <add key="quartz.threadPool.threadPriority" value="Normal" />
    <!-- Configure Job Store -->
    <add key="quartz.jobStore.misfireThreshold" value="60000" />
    <add key="quartz.jobStore.type" 
                  value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
    <add key="quartz.jobStore.useProperties" value="true" />
    <add key="quartz.jobStore.dataSource" value="default" />
    <add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
    <add key="quartz.jobStore.lockHandler.type"  
              value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />
    <add key="quartz.dataSource.default.connectionString" 
        value="Server=SVSQL2008;Database=QuartzNet1;Trusted_Connection=True;" />
    <add key="quartz.dataSource.default.provider" value="SqlServer-20" />
   </quartz>

There are few things to keep in mind depending if you’re hosting Quartz.net in a web application or a service or winform app.
The best approach is to create SchedulerFactory and Scheduler as singleton.
You can gather some more infos here.

UPDATE:

First of all you have to create Quartz.net tables (see Step 1) and then you’ll have to create a few indexes for optiomization (see bottom of the page).

Since you’re going to submit your jobs using the web app but you’re not using that app for the quartz.net events (triggers) you don’t need to start the scheduler.
There are few steps to follow on this side:

you have to change the thread pool type to ZeroSizeThreadPool

<add key="quartz.threadPool.type" 
                   value="Quartz.Simpl.ZeroSizeThreadPool, Quartz" />

and you have to define your StdSchedulerFactory and Scheduler singleton. You can start during the application (asp.net) bootstrap.

You’re never going to start the Scheduler (your windows service is going to use that).

Another thing to remember is you’re going to need share your job between your web and your windows service, so it would be better to keep it in a separate assembly.

You mentioned you’re storing some infos in one of your table.
You still need to have to submit your jobs and trigger which will be persisted in Quartz.net tables.

Leave a Comment