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

Compare with Current View Page History

« Previous Version 3 Next »

Could you show me a simple example of a job chain?

Question:

Does every job chain need an order to be triggered? Is there some simple example for the use of job chains and orders?

Answer:

Processing of a job chain is always triggered by an order. Therefore three elements have to be brought together: jobs, a job chain and an order.

The following example shows the XML view of the Job Chain - see JobScheduler - Tutorial 2 - Editing a Simple Job with JOE for an example Job Chain as seen in the JobScheduler's Editor, JOE.

  • Let's look at the job implementation. Any job could be used for a job chain, however the attribute order="yes" is required:

            <job name="command_1" title="sample_command" order="yes">
              <script language="shell">
                <![CDATA[
                 C:\Programme\Samples\Scripts\command_sample_1.cmd
                ]]>
              <script>
            </job>
    
            <job name="command_2" title="sample_command" order="yes">
              <script language="shell">
                <![CDATA[
                 C:\Programme\Samples\Scripts\command_sample_2.cmd
                ]]>
              <script>
            </job>
  • Next you need a job chain that assigns nodes and states to these jobs:

            <job_chain name="command_sequence">
              <job_chain_node state="first"
                  job="command_1"
                  next_state="second"
                  error_state="error"/>
              <job_chain_node state="second"
                  job="command_2"
                  next_state="success"
                  error_state="error"/>
              <job_chain_node state="success"/>
              <job_chain_node state="error"/>
            </job_chain>

     

    This sample assigns the above job command_1 the first node in the chain and command_2 the second node that will be executed if the first node were successfully completed. The chaining is organized by the next_state attribute that identifies the state of the next job node in a chain and respectively the error_state attribute that identifies the node that should be executed in case of error. Job nodes for final states could be empty as for success and error, moreover you could create job implementations for individual error handling.

  • Last but not least you need an order that triggers the execution of the job chain:

            <order job_chain="command_sequence"
              title="sample command sequence" replace="yes">
              <params/>
                <!-- sample run time: repeat the execution of this order
                     every day at the given time -->
                <run_time><period single_start="23:36"/></run_time>
            </order>
     

    This order is used for three purposes:

    • Trigger the execution of the job chain: You would not start a job chain by starting the first job node, but by starting the order. The built-in HTML interface of JobScheduler offers the respective operations for orders. Multiple orders could cause the parallel execution of jobs in a job chain. JobScheduler would then dynamically allocate tasks in parallel to these jobs.
    • Add parameters to the jobs within the job chain: Parameters from orders are added with precedence to the parameters of a job configuration

              <job>
                  <params>
                      <param name="sample_name" value="sample_value">
                  </params>
              </job>
    • Specify the run time for automated execution: Any periods for repeated execution could be set.

You could ask, why an order is required if parameters and run time periods could equally be added to jobs? The answer is: re-usability of jobs and job chains. You can use multiple orders for the same job chain with different parameter sets.

  • No labels