Examples of using loop stages
You can use loop stages to build loops into your job sequences.
The following is a section of a job sequence that makes repeated attempts to run a job until either it succeeds, or until the loop limit is reached. The job depends on network link that is not always available.
The Start Loop stage, networkloop, has Numeric loop selected and the properties are set as follows:
This defines that the loop will be run through up to 1440 times. The action differs according to whether the job succeeds or fails:
- If it fails, the routine waitabit is called. This implements a 60 second wait time. If the job continually fails, the loop repeats 1440 times, giving a total of 24 hours of retries. After the 1440th attempt, the End Loop stages passes control onto the next activity in the sequence.
- If it succeeds, control is passed to the notification stage, emailsuccess, and the loop is effectively exited.
The following is a section of a job sequence that makes use of the loop stages to run a job repeatedly to process results for different days of the week:
The Start Loop stage, dayloop, has List loop selected and properties are set as follows:
The Job Activity stage, processresults, properties are:
The job processresults will run five times, for each iteration of the loop the job is passed a day of the week as a parameter in the order monday, tuesday, wednesday, thursday, friday. The loop is then exited and control passed to the next activity in the sequence.