Frage

I have a Asp.net C# MVC 3 application implementing the Sharp Architecture. I have been trying to get Quartz.net to setup and work nicely with Castle Windsor for a few days without any luck. Based on what I know, I have setup everything correctly, but continue to have issues.

In my Global.cs file, creating my Container and trying to register quartz jobs:

var container = new WindsorContainer(new XmlInterpreter("quartz_jobs.xml"));
container.AddFacility("quartznet", new QuartzFacility());

In my quartz_jobs.xml file I have the following contents:

<?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>DeleteLoansWithoutClientsJob</name>
        <job-type>EasyOptions.Web.Mvc.Code.Jobs.DeleteLoansWithoutClientsJob, EasyOptions.Web.Mvc</job-type>
        <durable>true</durable>
    </job-detail>
    <trigger>
        <cron>
            <name>DeleteLoansWithoutClientsJobTrigger</name>
            <group>MyJobs</group>
            <description>A description</description>
            <job-name>DeleteLoansWithoutClientsJob</job-name>
            <job-group>MyJobs</job-group>
            <cron-expression>0 0/1 * * * ?</cron-expression>
        </cron>
    </trigger>
</job>

War es hilfreich?

Lösung

Problem is, you're pointing Windsor to the Quartz.NET config file.

There are two separate configurations: Windsor's and Quartz.NET's. Windsor is usually configured with code nowadays (i.e. fluent config), though it still supports XML configuration. However the Quartz.NET facility doesn't currently support code config, you have to use Windsor's XML config (at least for this, other components/facilities may still be configured via code). Then there's Quartz.NET, usually configured via an external quartz_jobs.xml file.

I recommend using the Quartz.NET facility sample app as reference. In particular, here's the sample Windsor config and the sample Quartz.NET config.

EDIT: if Quartz.NET says it can't find quartz_jobs.xml in a web application you need to include the web root in the configuration path: "~/quartz_jobs.xml" (instead of plain "quartz_jobs.xml")

Andere Tipps

I've written a blog post on how to integrate Quartz.NET with an IoC container. My example code uses Castle Windsor.

The blog post can be found here: http://thecodesaysitall.blogspot.com/2012/02/integrate-quartznet-with-your-favourite.html

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top