在asp.net配置XML quartz.net [英] quartz.net from config xml in asp.net

查看:180
本文介绍了在asp.net配置XML quartz.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能劝什么我做错了。
我想设置qurtz,这样在启动时它会读取XML配置文件。里面的文件也能激活我的HelloEmail_Job.cs类(它是正确创建的,在执行方法IJob的逻辑延伸)的工作。在XML也有,这将触发每分钟(纯粹是为了测试)工作

Can someone advise on what I am doing wrong. I am trying to setup qurtz so that on startup it will read an xml config file. inside the file there is a job that activates my HelloEmail_Job.cs class (it is created correctly, extending IJob with the logic in the execute method). the xml also has a cron trigger for the job that will fire every minute (purely for testing)

但一切都启动时没有错误,但工作永远不会触发。我相信我错配置

but everything starts up without an error, but the job never fires. i am sure I am configuring wrong

我有我的处理调度的生成单,在程序器启动我的应用程序启动(在Global.asax文件)

I have a singleton that handles the generation of my scheduler, the schedular starts on startup of my app (in the global.asax file)

    NameValueCollection properties = new NameValueCollection();
    properties["quartz.scheduler.instanceName"] = "RemoteServer";

    ////// set thread pool info
    properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
    properties["quartz.threadPool.threadCount"] = "5";
    properties["quartz.threadPool.threadPriority"] = "Normal";

    properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
    properties["quartz.jobStore.useProperties"] = "true";
    properties["quartz.jobStore.dataSource"] = "default";
    properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
    properties["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz";

    properties["quartz.dataSource.default.connectionString"] = "Data Source=CRAIG-PC\\SQLEXPRESS;Initial Catalog=MCWdb;User ID=sa;Password=mastercrud;";
    properties["quartz.dataSource.default.provider"] = "SqlServer-20";

    // job initialization plugin handles our xml reading, without it defaults are used
    properties["quartz.plugin.xml.type"] = "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz";
    properties["quartz.plugin.xml.fileNames"] = "~/quartz_jobs.xml";

    ISchedulerFactory sf = new StdSchedulerFactory(properties);
    _sched = sf.GetScheduler();

我quartz_jobs.xml文件看起来像这样

my quartz_jobs.xml file looks like this

        <?xml version="1.0" encoding="UTF-8"?>

        <job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        version="2.0">

          <processing-directives>
            <overwrite-existing-data>true</overwrite-existing-data>
          </processing-directives>

          <schedule>        
                <job> 
                  <job-detail> 
                    <name>MyJob</name> 
                    <group>MyJobs</group> 
                    <description>sends out a test email</description>
                      <job-type>HelloEmail_Job</job-type>
                      <volatile>false</volatile> 
                    <durable>true</durable> 
                    <recover>false</recover> 
                    <job-data-map> 
                      <entry> 
                        <key>Body</key> 
                        <value>Hello From your website!!!!!!!!</value> 
                      </entry> 
                    </job-data-map> 
                  </job-detail> 
                  <trigger> 
                    <cron> 
                      <name>MyJobTrigger</name> 
                      <group>MyJobs</group> 
                      <description>A description</description> 
                      <job-name>MyJob</job-name> 
                      <job-group>MyJobs</job-group> 
                      <cron-expression>0 0/1 * 1/1 * ? *</cron-expression> 
                    </cron> 
                  </trigger> 
                </job>
            </schedule>

        </job-scheduling-data>

我知道程序器与一个简单的触发正确运行的特设工作,因为当我的应用程序创建它们,并调度它们动态地将其完美的作品。但我希望做重复的(通过cron)逻辑和可配置通过XML

I know that the schedular is running correctly for ad hoc jobs with a simple trigger because when my app creates them and schedules them dynamically it works perfectly. but I want the logic made repeatable (through a cron), and configurable through a xml

我的直觉是,JOB_TYPE值是错误的。

my gut feeling is that the JOB_TYPE value is wrong.

感谢

推荐答案

您的工作类型需要被指定为

Your job type needs to be specified as

<job-type>Fully.Qualified.Type.Name, AssemblyNameWithoutTheDllExtension</job-type>

这篇关于在asp.net配置XML quartz.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆