Chima Osuji
Chima Osuji

Reputation: 391

Quartz .NET job-type configuration issues

I've been dumbfounded by what I suspect is an oversight on my part in the setting up of a Quartz .NET configuration file. I've searched the forum for similar posts, with this post 'quartz.net from config xml in asp.net' being the most relevant, but unfortunately it has not helped. I'd appreciate any help or advice people can think of.

I am attempting to load a configuration file to schedule some jobs using Quartz version 1. My app.config file defines the the Quartz configuration:

<quartz>
        <add key="quartz.scheduler.instanceName" value="QuartzScheduler" />
        <!-- 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.type" value="Quartz.Simpl.RAMJobStore, Quartz" />
        <add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.JobInitializationPlugin, Quartz" />
        <add key="quartz.plugin.xml.fileNames" value="~/configuration/quartz_jobs.config" />
        <add key="quartz.plugin.xml.scanInterval" value="10" />
    </quartz>

Then my quartz_jobs.config file defines the jobs:

<?xml version="1.0" encoding="UTF-8"?>
<quartz xmlns="http://quartznet.sourceforge.net/JobSchedulingData"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                version="1.0"
                overwrite-existing-jobs="true">

    <job>
        <job-detail>
            <name>jobName1</name>
            <group>jobGroup1</group>
            <description>jobDesciption1</description>
            <job-type>FundDataImportScheduler.Jobs.FsdImportJob, FundDataImportScheduler</job-type>
            <volatile>false</volatile>
            <durable>true</durable>
            <recover>false</recover>
        </job-detail>

        <trigger>
            <cron>
                <name>cronName1</name>
                <group>cronGroup1</group>
                <description>CronTriggerDescription</description>
                <job-name>jobName1</job-name>
                <job-group>jobGroup1</job-group>
                <cron-expression>0 0/1 * * * ?</cron-expression>
            </cron>
        </trigger>
    </job>
</quartz>

Please note the node in the quartz_jobs.config file. I am trying to load the class that implements IJob:

public class FsdImportJob : IJob
{
   public void Execute(JobExecutionContext context)
   {
     Console.WriteLine("FsdImportJob triggered");
   }
}

The issue I am having is, when the node equals "FundDataImportScheduler.Jobs.FsdImportJob, FundDataImportScheduler", the job is not loaded. If I test using a value of "Quartz.Job.NativeJob, Quartz" in the node, a job is loaded (not the one I want though).

FundDataImportScheduler.Jobs.FsdImportJob is the exact namespace of the class FsdImportJob, and FundDataImportScheduler is the dll it is compiled into.

For completeness, the code I am using to build the Quartz SchedulerFactory and load the configuration is:

ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
IScheduler scheduler = schedulerFactory.GetScheduler();
scheduler.Start();

I would appreciate any pointers as to where I am going wrong.

Many thanks,

Chima

Upvotes: 1

Views: 5137

Answers (1)

Chima Osuji
Chima Osuji

Reputation: 391

Well, now I feel a bit silly - the problem was because I initially had the FsdImportJob class in console app. Quartz was expecting a FundDataImportScheduler.dll, but of course there was only a FundDataImportScheduler.exe.

Once I moved the FsdImportJob out into a class library, Quartz was able to load the .dll the library compiled, and thus load the FsdImportJob class.

Many thanks,

Chima

Upvotes: 1

Related Questions