Scheduling a Quartz.Net Job Using Xml

Quartz.Net ships with a plugin that allows you to schedule jobs using an xml configuration file. By default this configuration file is called quartz_jobs.xml. In this post I will describe how to schedule a job with a cron trigger using this xml format.

Here are the contents of the XML file:

<?xml version="1.0" encoding="UTF-8"?>
<job-scheduling-data xmlns="" xmlns:xsi="" version="2.0">
            <description>My Job</description>
            <job-type>MyAssembly.MyJob, MyAssembly</job-type>
                    <value>data source=dbserver;initial catalog=db1;user id=userid;pwd=password;</value>
                    <value>data source=dbserver;initial catalog=db2;user id=userid;pwd=password;</value>

            &lt;description&gt;Cron trigger for MyJob&lt;/description&gt;
            &lt;cron-expression&gt;0 0 2 * * ?&lt;/cron-expression&gt;



I’ll point out a few things of interest and we’ll call this post done, since as you can see the xml is quite self explanatory.

1. Notice the <job-data-map> element at line 14. This is how we can pass parameters to our job via the JobDataMap. This JobDataMap can be accessed from context. In this case we are passing 2 connection strings to our job so that it can do its thing.

2. Notice in the trigger element how we are creating a cron trigger on line 28, instead of a simple trigger. In this case, the trigger will fire every day at 2AM.

That’s it! This example illustrates how to schedule a job with a cron trigger and with some data being passed in to the JobDataMap.