You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Setback

Question:
How can I make a job to retry in case of errors?

Downloads:



Instructions:

  • Unzip all files into the ./config/live folder of your JobScheduler installation.
  • Open the web interface of the JobScheduler in your browser using http://scheduler_host:scheduler_port
  • Open the JOB CHAINS tab and enable "Show orders".
  • Find the job chain samples/setback/chain_setback.
  • Find the order order1, open the order menu and choose "Show log".

A window will open showing the log of the order. As the order isn't running yet, the window will show nothing more than a line indicating the next start time of this order. Leave the window open and move it to a place where you can see it along with the main browser window.

  • Start the order by choosing "Start order now" from the Order menu.
  • Watch the log grow in the other window

The order will run into the first job (setback) of the chain. This job simulates an error and sets the order back into the queue. 20 seconds later, the JobScheduler will make the job process the order again. Like the last time the order will be setback.

On the third try, a successfull completion of the job is simulated (e.g. the network connection is working again). The order will then continue into the second job of the job chain.



How it works:

The order has an initial order parameter count which is set to 1. The first job (setback) reads this parameter. If the parameter is not 3, it is increased and the job calls the order's setback() function (which is what a job should do in case of errors that might be temporary).

A setback interval is configured at the job:

<!-- after the first setback, try again every 20 seconds -->
<delay_order_after_setback setback_count="1" delay="20"/>
<!-- after the 100th setback, try again every 60 seconds -->
<delay_order_after_setback setback_count="100" delay="60"/>
<!-- after the 1000th setback, give up -->
<delay_order_after_setback setback_count="1000" is_maximum="yes"/>

Calling setback() will cause the JobScheduler to retry processing this order or to give up if the maximum is reached.

When the count paramter of the order has reached 3, success is simulated. The job does not setback the order this time and the order is able to run through the following jobs.

  • No labels