Skip to end of metadata
Go to start of metadata

Introduction 

This example configures a job chain which is made up of three other job chains.

  • The check_day job is positioned at the start of the middle job chain and is used to test if the skip condition is met.
  • If the condition is met then the order state for the middle job chain will be changed as required.
  • In the example, the "main" job in the middle job chain is skipped on certain days.

Downloads

Instructions

  • Unzip all files into the ./config/live folder of your JobScheduler installation.
  • Open the JobScheduler Operating Center, JOC, in your browser using http://scheduler_host:scheduler_port
  • Open the JOB CHAINS tab and enable "Show orders".
  • Find the job chain samples/meta_chains_skip/big_chain.
  • Click on that chain. In the right window you will see that this job chain consists of 3 other chains: chain_a, chain_b and chain_c and that whilst all three job chains have a common job, readparam, chain_b has an additional job, check_day.
  • On the left side click on samples/meta_chains_skip/chain_a
  • Find the order my_order and press "Start order now" in the Order menu.

The order will now move through the 3 job chains. If today is the 12th day of the month, only the first job (check_day) of the chain_b will be executed and the rest of the job chain will be skipped.

Click on samples/meta_chains_skip/chain_b and enable show_order_history on the right side and view the log of the order that just passed through the chain. If it's not the 12th day of the month you should see that the order has moved through both jobs check_day and read_param.

The check_day job
<?xml version="1.0" encoding="ISO-8859-1"?>

<job  order="yes" stop_on_error="no">
    <script  language="javax.script:ecmascript">
        <![CDATA[
    function spooler_process(){
      var today = new Date();
      var day_of_month = today.getDate();
      if (day_of_month == 12){
        spooler_log.info("Today is the 12th - skipping job chain b");
        spooler_task.order().set_state("end_of_chain_b");
      }
      return true;
    }
        ]]>
    </script>
    <run_time />
</job>

 

  • Edit ./config/live/samples/meta_chains_skip/check_day.job.xml,  either with a code editor or with JOE - JobScheduler Object Editor
  • Change day_of_month == 12 to check for the current day and save

Once JobScheduler has noticed the change in the configuration file, it will update the job definition. This may take up to one minute on non-Windows machines.

  • Start the order again as described above
  • Check the new log in the history of samples/meta_chains_skip/chain_b to see that the order has skipped the rest of the chain.

How it works:

The change to the order state carried out by the set_state() causes JobScheduler to go to the end state of the current (in this case, the middle) job chain. The JobScheduler skips the jobs in between and ignores the return value of the job and the next_state and error_state configuration of the job chain node.

 

Write a comment…