repeat

Description

This job will repeatedly run it's child job. The repeats are determined by schedules. An optional regular schedule and an optional retry schedule can be configured.

A repeat without a schedule will execute once.

An exception job can be configured which will be run if the child either doesn't complete or ends in an exception state. If a retry schedule is specified then the exception job won't be triggered until the retry schedule expires.

This job is deprecated. Prefer scheduling:timer and scheduling:retry instead as they don't cause a thread to sleep that might be doing useful work. This job may be re-written in a non time based form. Possibly as repeat until a job state or repeat for a count. The use cases still need to be discovered.

Properties

NameDescriptionRequired
name A name, can be any text. No.
schedule A schedule for normal completion. It defaults to immediately. No.
retry The schedule used in the event that the child job doesn't complete or is in an exception state. No.
scheduleDate This is the start of the last normal schedule. The schedule date is used when the retry schedule polls past midnight, yet your business data is from the day before. The schedule date provides a consistent business date which can useful as the date for file names etc. No.
job The job who's execution to schedule. Yes.
exception Add a job to execute in the event that the child job has not completed or is in an exception state and the retry schedule has expired or there was no retry schedule. No.

Example

 <repeat xmlns:schedules="http://rgordon.co.uk/oddjob/schedules 
            name="Repeat 10 times">
   <schedule>
      <schedules:count count="10"/>
   </schedule>
   <job>
     <sequential>
       <sequence id="seq"/>
       <echo text="Hello ${seq.current}"/>
     </sequential>
   </job>
 </repeat>
 

 <repeat xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"
            name="Repeat immediately until complete">
   <retry>
      <schedules:now/>
   </retry>
   <job>
        <random class="org.oddjob.samples.RandomTask"/>
   </job>
 </repeat>
 

 <repeat name="Try 10 times, 1 seconds apart, before alerting">
   <retry>
      <count count="10">
      	<interval interval="00:00:01"/>
      </count>
   </retry>
   <child>
     <oddjob file="doesnt.exist"/>
   </child>
   <exception>
     <echo text="Help!"/> 
   </exception>
 </repeat>
 


(c) Rob Gordon 2005 - 2009