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

时间:2010-08-24 18:56:56

标签: spring.net quartz.net

是否有可能以串行方式永久重复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循环。

1 个答案:

答案 0 :(得分:7)

'RepeatCount'设置为'-1'