如何使用 Quartz XML 插件声明一次性简单触发器? [英] How do I declare a one-time simple trigger with the Quartz XML plugin?

查看:34
本文介绍了如何使用 Quartz XML 插件声明一次性简单触发器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个作业,使其在我的调度程序第一次启动时运行一次,然后在之后每天午夜运行一次.这是我的作业和触发器的 XML.一天一次触发有效,但一次性触发无效.

I'm trying to set up a job such that it runs once the first time my scheduler is started, then once at midnight every day after that. Here is my XML for the job and triggers. The once a day trigger works, but the one-time trigger does not.

    <job>
      <name>MyJob</name>
      <group>MyJobGroup</group>
      <job-type>MyScheduledJob, MyJobAssembly</job-type>
      <description>My job, yo</description>
      <durable>true</durable>
      <recover>false</recover>
    </job>
    <trigger>
      <cron>
        <name>MyTrigger</name>
        <group>MyTriggerGroup</group>
        <job-name>MyJob</job-name>
        <job-group>MyJobGroup</job-group>
        <cron-expression>0 0 0 1/1 * ? *</cron-expression>
      </cron>
        <simple>
            <name>MyOneTimeTrigger</name>
            <group>MyTriggerGroup</group>
            <description>Run once at startup, G</description>
            <misfire-instruction>SmartPolicy</misfire-instruction>
            <volatile>false</volatile>
            <job-name>MyJob</job-name>
            <job-group>MyJobGroup</job-group>
            <repeat-count>0</repeat-count>
            <repeat-interval>0</repeat-interval> 
      </simple>
    </trigger>

推荐答案

不起作用 我猜你的意思是触发器永远不会触发.也许是因为它没有延迟它会失火?在未来的某个时间添加 怎么样?

By doesn't work I guess you mean the trigger never fires. Maybe because it has no delay it misfires? What about adding <start-time-seconds-in-future/> with some time in the future?

<simple>
        <name>MyOneTimeTrigger</name>
        <group>MyTriggerGroup</group>
        <description>Run once at startup, G</description>
        <misfire-instruction>SmartPolicy</misfire-instruction>
        <volatile>false</volatile>
        <job-name>MyJob</job-name>
        <job-group>MyJobGroup</job-group>
        <start-time-seconds-in-future>60</start-time-seconds-in-future>
        <repeat-count>0</repeat-count>
        <repeat-interval>0</repeat-interval> 
</simple>

如果它对你有用,你必须知道一些你可能认为是错误或功能的东西:如果你重新启动服务器,因为触发器已经触发并被删除,它会再次触发.请参阅:Quartz XML 插件重新安排重启后触发的触发器.

If it works for you, you must be aware of something which you might consider either a bug or a feature: if you restart the server, because the trigger already fired and was removed, it will fire again. See: Quartz XML plugin reschedules fired triggers after restart.

这篇关于如何使用 Quartz XML 插件声明一次性简单触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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