4

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.

Lieven Cardoen
  • 25,140
  • 52
  • 153
  • 244

1 Answers1

8

'RepeatCount' set to '-1'

Aito
  • 6,812
  • 3
  • 30
  • 41
  • I get an error: [Spring.Core.TypeMismatchException: Cannot convert property value of type [System.String] to required type [System.TimeSpan] for property 'RepeatInterval'., Inner Exception: System.ArgumentException: Repeat interval must be >= 0 at Quartz.SimpleTrigger.set_RepeatInterval(TimeSpan value) at _dynamic_Quartz.SimpleTrigger.set_RepeatInterval(Object , Object , Object[] ) – Lieven Cardoen Aug 24 '10 at 19:13
  • 1
    If I do not set it at all, I get the error saying it can't be zero. – Lieven Cardoen Aug 24 '10 at 19:14
  • Ok, I see what you mean. But...if you need only an infinite loop (and not schedule anything) I don't see why you want to use Quartz. Just use a while loop. If you want to repeat the cycle for ever try to use both properties: RepeatInterval (<> 0) and RepeatCount (-1). I hope it helps you.. – Aito Aug 24 '10 at 19:21
  • Indeed, a while loop would be better. – Lieven Cardoen Aug 25 '10 at 06:48
  • I guess I wanted to do some r&d on quartz and in this case quartz would just handle creating a thread for one job. – Lieven Cardoen Aug 25 '10 at 06:51