Page History
...
Download: retry-on-return-code.workflow.json
Retry Block
A Retry Block in a JS7 - Retry Instruction includes any number of jobs or instructions. If one of them fails then processing will be repeated from the beginning of the block.
...
Explanation:
- This workflow implements
- an outer Retry Block to repeat execution,
- an inner Try / Catch Block to handle specific exit codes of the job Job Instruction that fails with varying return codes,
- an inner If Instruction to decide about the handling of specific return codes.
Try Block
...
Job
The job is implemented to complete with varying return codes that are handled like this:
Explanation:
- Return code 0 signals success and the job will continue after the Retry-End Instruction.
- Return code 1 and 2 similarly are considered successful, however, they are handled by the subsequent If Instruction.
If Instruction
The JS7 - If Instruction applies
Explanation:
- After a first job
job1
thejob2
should be restarted for a number of times if it fails with return code 1. - The JS7 - Retry Instruction manages the retry capability and the intervals.
- The properties of the Retry Instruction include to specify a common delay for any retries or to use individual delays per retry.
- The JS7 - Try / Catch Instruction
- executes any number of instructions and jobs within the Try Block.
- Should the jobs complete successfully then processing will continue after the Catch Block.
- Should jobs fail then the instructions and jobs inside the Catch Block will be executed.
- executes any number of instructions and jobs within the Try Block.
Catch Block
The Catch Block is executed in case of failed instructions or jobs in a Try Block.
The solution makes use of an JS7 - If Instruction to apply different types of error handling depending on the return code reported by the failed job.:
...
Explanation:
- Within the Catch Retry Block the JS7 - If Instruction is used to check the return code value which gives two options:
- if the return code value is 1 then the left branch (true) of the If Instruction is used,
- for any other return code values the right branch (false) is used.
- This is achieved by use of a predicate that checks the built-in
$returnCode
variable, see JS7 - Expressions for Variables. - Subsequently we find two occurrences of a JS7 - Fail Instruction.
Left Fail Instruction
...
Explanation:
- The left Fail Instruction fails the order with a return code value 1.
- In addition, a message can be added that becomes visible with the JOC Cockpit GUI for the failed order.
- As a consequence the failed order is immediately picked up by the outer Retry Instruction that will repeat execution of
job1
having applied the indicated delay.
Right Fail Instruction
Explanation:
...