repeat

Description

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

It might not be immediately obvious why a repeat job should involve schedules but frequently a job will be repeated because it fails and that failure will be due to a network connection or database failure where immediate retries are unnecessary and can impact on overall system resources. It's often much better to wait a few seconds before retrying. This effect could be achieved using a scheduler but a scheduler is sometimes to heavy-weight especially if there are only a few jobs to run.

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.

Properties

NameDescriptionRequired
name A name, can be any text. No.
normalSchedule A schedule for normal completion. It defaults to immediately. 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.

Elements

retry

Required: No.

The schedule used in the event that the child job doesn't complete or is in an exception state.

child

Required: Yes.

The job to run.

exception

Required: No.

The job to run on failure.

addComponentChild

Required: Yes.

exception

Required: No.

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.

Example

 <repeat name="Repeat 10 times">
   <schedule>
      <count count="10"/>
   </schedule>
   <child>
     <sequential>
       <sequence id="seq"/>
       <echo text="Hello ${seq.current}"/>
     </sequential>
   </child>
 </repeat>
 

 <repeat name="Repeat immediately until complete">
   <retry>
      <now/>
   </retry>
   <child>
        <random class="org.oddjob.samples.RandomTask"/>
   </child>
 </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