这是我的XML文件,它根本不工作。我想使用XML文件配置多个作业,我搜索了这个并没有得到答案,所以有人可以帮我解决这个问题吗?
<schedule>
<job>
<name>employee</name>
<group>SampleGroup</group>
<description>My job</description>
<job-type>Quartz.Server.Interface_manip, Quartz.Server</job-type>
<durable>true</durable>
<recover>false</recover>
</job>
<trigger>
<cron>
<name>employeeTrigger</name>
<group>SampleGroup</group>
<description>Simple trigger to simply fire sample job</description>
<job-name>employee</job-name>
<job-group>SampleGroup</job-group>
<misfire-instruction>SmartPolicy</misfire-instruction>
<cron-expression>0 13 10 * * ?</cron-expression>
</cron>
</trigger>
<job>
<name>SampleJob</name>
<group>SampleGroup</group>
<description>My job</description>
<job-type>Quartz.Server.Next_Year_Quota, Quartz.Server</job-type>
<durable>true</durable>
<recover>false</recover>
</job>
<trigger>
<cron>
<name>SampleTrigger</name>
<group>SampleGroup</group>
<description>Simple trigger to simply fire sample job</description>
<job-name>SampleJob</job-name>
<job-group>SamplerGroup</job-group>
<misfire-instruction>SmartPolicy</misfire-instruction>
<cron-expression>0 31 10 * * ?</cron-expression>
</cron>
</trigger>
</schedule>
</job-scheduling-data>
如果只有第一个作业,它会完美执行,当我添加第二个作业时它没有做任何事情,但我真的需要它来执行多个作业,并且使用XML会很方便。谢谢你许多。
答案 0 :(得分:1)
从我可以看到你的问题是由于你正在将你的工作分组并一起触发。尝试将您的工作分组,并将您的触发器组合在一起。 此外,我不知道您是否打算排除xml和作业调度数据标记,但是您需要这些标记。
另外,我觉得这个工具很有帮助。 Cron Expression Generator & Explainer - Quartz
试试这个:
<?xml version="1.0" encoding="utf-8" ?>
<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData">
<schedule>
<job>
<name>employee</name>
<group>SampleGroup</group>
<description>My job</description>
<job-type>Quartz.Server.Interface_manip, Quartz.Server</job-type>
<durable>true</durable>
<recover>false</recover>
</job>
<job>
<name>SampleJob</name>
<group>SampleGroup</group>
<description>My job</description>
<job-type>Quartz.Server.Next_Year_Quota, Quartz.Server</job-type>
<durable>true</durable>
<recover>false</recover>
</job>
<trigger>
<cron>
<name>employeeTrigger</name>
<group>SampleGroup</group>
<description>Simple trigger to simply fire sample job</description>
<job-name>employee</job-name>
<job-group>SampleGroup</job-group>
<misfire-instruction>SmartPolicy</misfire-instruction>
<cron-expression>0 13 10 * * ?</cron-expression>
</cron>
</trigger>
<trigger>
<cron>
<name>SampleTrigger</name>
<group>SampleGroup</group>
<description>Simple trigger to simply fire sample job</description>
<job-name>SampleJob</job-name>
<job-group>SamplerGroup</job-group>
<misfire-instruction>SmartPolicy</misfire-instruction>
<cron-expression>0 31 10 * * ?</cron-expression>
</cron>
</trigger>
</schedule>
</job-scheduling-data>