Passing a value from a parent Job to a child Job


Passing a value from the parent Job to the child Job is a common real world requirement. This article serves as a best practice guide.



This procedure was written with:

  • Talend Open Studio for DI 5.0-r72978
  • JDK version: Sun JDK build 1.6.0_26-b03
  • Operating system: Windows XP SP3

The following environment was used to create the suggested procedure.

  • Data Integration releases: 4.2.3, 5.0, 5.0.2, 5.1.1



This example reads data from a text file in a parent Job and passes fields from each row to the child Job. The data is used in the child Job.




Create Parent Job

Create a Job called ParentJob. The Job design is as follows. (You will configure tRunJob in the configuration step).




Create Child Job

Create a child Job. Call it ChildJob.

  1. Drag and drop a tJava component from the Palette to the Job editor. In the tJava component, type in the following Java code:

    String message="Hello "", you get "+context.scope+" points in this exam!";
  2. Open the Contexts viewer, and define two context variables: name and scope, as follows:



Configure Component

Return to the parent Job, configure the tRunJob component as follows:



Execute Parent Job

Execute the Job ParentJob. The following results will print to the console:

Starting job ParentJob at 11:38 12/12/2011.
[statistics] connecting to socket on port 3768
[statistics] connected
Hello Shong, you get 98 points in this exam!
Hello Ross, you get 90 points in this exam!
Hello Tom, you get 55 points in this exam!
Hello Patrick, you get 99 points in this exam!
Hello Pedro, you get 90 points in this exam!
[statistics] disconnected
Job ParentJob ended at 11:38 12/12/2011. [exit code=0]



The most important technical point is using the context variable, defined in the child Job, to pass a value from parent Job to child Job.

Version history
Revision #:
4 of 4
Last update:
‎02-25-2019 01:17 AM
Updated by:
Labels (2)