如何在 Quartz 中安排一个永远重复的工作?

发布于 2024-09-16 00:18:42 字数 1594 浏览 6 评论 0原文

是否有可能以串行方式永远重复 Quartz 中的作业?

现在,如果我不设置 RepeatInterval,则会收到一条错误消息,指出 RepeatInterval 不能为零。

是否可以使用 Spring.NET 进行配置?我现在所拥有的是:

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
  <object id="ExampleBusinessObject" type="Edu3.Core.Job.ExampleJob, Edu3.Core"/>

  <object id="JobDetail" 
          type="Spring.Scheduling.Quartz.MethodInvokingJobDetailFactoryObject,
                Spring.Scheduling.Quartz">
    <property name="TargetObject" ref="ExampleBusinessObject" />
    <property name="TargetMethod" value="DoIt" />
    <property name="Concurrent" value="false" />
  </object>

  <object id="SimpleTrigger" 
          type="Spring.Scheduling.Quartz.SimpleTriggerObject, 
                Spring.Scheduling.Quartz">
    <!-- see the example of method invoking job above -->
    <property name="JobDetail" ref="JobDetail" />
    <!-- 10 seconds -->
    <!--<property name="StartDelay" value="5s" />-->
    <!-- repeat every 50 seconds -->
    <property name="RepeatInterval" value="10s" />
  </object>

  <object id="quartzSchedulerFactory" 
          type="Spring.Scheduling.Quartz.SchedulerFactoryObject,
                Spring.Scheduling.Quartz">
    <property name="triggers">
      <list>
        <ref object="SimpleTrigger" />
      </list>
    </property>
  </object>
</objects>

我不希望不同的线程执行相同的作业。我只想触发 DoIt。如果DoIt完成,则再次触发DoIt。就像一个不定式 while 循环。

Is it possible to repeat a job in Quartz forever in a serial way?

Now, if I don't set RepeatInterval I get an error saying that RepeatInterval cannot be zero.

Is it possible to configure this using Spring.NET? What I have now is this:

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
  <object id="ExampleBusinessObject" type="Edu3.Core.Job.ExampleJob, Edu3.Core"/>

  <object id="JobDetail" 
          type="Spring.Scheduling.Quartz.MethodInvokingJobDetailFactoryObject,
                Spring.Scheduling.Quartz">
    <property name="TargetObject" ref="ExampleBusinessObject" />
    <property name="TargetMethod" value="DoIt" />
    <property name="Concurrent" value="false" />
  </object>

  <object id="SimpleTrigger" 
          type="Spring.Scheduling.Quartz.SimpleTriggerObject, 
                Spring.Scheduling.Quartz">
    <!-- see the example of method invoking job above -->
    <property name="JobDetail" ref="JobDetail" />
    <!-- 10 seconds -->
    <!--<property name="StartDelay" value="5s" />-->
    <!-- repeat every 50 seconds -->
    <property name="RepeatInterval" value="10s" />
  </object>

  <object id="quartzSchedulerFactory" 
          type="Spring.Scheduling.Quartz.SchedulerFactoryObject,
                Spring.Scheduling.Quartz">
    <property name="triggers">
      <list>
        <ref object="SimpleTrigger" />
      </list>
    </property>
  </object>
</objects>

I don't want different threads executing the same job. I just want DoIt to be triggered. If DoIt is finished, then DoIt is triggered again. Like a infinitive while loop.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥有 2024-09-23 00:18:42

“重复计数”设置为“-1”

'RepeatCount' set to '-1'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文