Scenario 2: Running a list of child Jobs dynamically - 6.3

Talend Open Studio for Big Data Components Reference Guide

EnrichVersion
6.3
EnrichProdName
Talend Open Studio for Big Data
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

This scenario describes a Job that calls two child Jobs dynamically. When called from the parent Job, each of these simple child Jobs displays a message on the console.

Setting up the child Jobs

  1. Create a Job named child_1, and add two components by typing their names on the design workspace or dropping them from the Palette:

    • a tFixedFlowInput, to generate a message

    • a tLogRow, to display the generated message on the console.

  2. Connect the tFixedFlowInput component tLogRow using a Row > Main connection.

  3. Double-click the tFixedFlowInput component to open its Basic settings view.

  4. Click the [...] button next to Edit schema to open the [Schema] dialog box and define the schema of the input data.

    In this example, the schema has only one column: Message (type string).

    When done, click OK to close the dialog box and click Yes when prompted to propagate the schema to the next component.

  5. Select the Use Inline Content option, and enter the message you want to show on the console in the Content field, Hello World! in this example.

  6. In the Basic settings view of the tLogRow component, select the Table mode to display the execution result in table cells.

  7. Create copy of this Job and name it child_2, and enter another message in the Content field of the tFixedFlowInput component, Hello Talend! in this example.

  8. Press Ctrl+S to save the Jobs.

Setting up the parent Job

Adding and link components

  1. Create a new Job and add the following components by typing their names on the design workspace or dropping them from the Palette:

    • a tFixedFlowInput, to specify a list of Jobs to be called dynamically,

    • a tFlowToIterate, to iterate on the input rows and store the content into an iterative global variable,

    • a tRunJob, to load and run the child Jobs

  2. Connect the tFixedFlowInput component to the tFlowToIterate component using a Row > Main connection.

  3. Connect the tFlowToIterate component to the tRunJob component using a Row > Iterate connection.

Configuring the components

  1. Double-click the tFixedFlowInput component to open its Basic settings view.

  2. Click the [...] button next to Edit schema to open the [Schema] dialog box and define the schema of the input data.

    In this example, the schema has only one column: Job (type string).

    When done, click OK to close the dialog box and click Yes when prompted to propagate the schema to the next component.

  3. Select the Use Inline Content option, and specify the names of the child Jobs to call from the parent Job in the Content field:

    child_1
    child_2
  4. Double-click the tRunJob component to open its Basic settings view.

  5. Select the Use dynamic job check box.

  6. Click in the Context job field, press Ctrl+Space and from the list of variables select the iterative global variable created by the tFlowToIterate component, Job in this example. The Context job field is then filled with ((String)globalMap.get("row1.Job")). Upon each iteration, this variable will be resolved as the name of the Job to be called.

  7. Click the [...] button next to the Job field to open the [Select Job] dialog box. Select all the Jobs you want to run and click OK to close the dialog box.

  1. Press Ctrl+S to save the Job.

  2. Press F6 or click the Run button on the Run console to execute the Job.

    The child Jobs are called one after another and messages specified in the child Jobs are displayed on the console.