You may need to return a value or rows from a child Job to the parent Job for further use. This article shows the best practice of how to pass a value with a tBufferOutput component from a child Job to the parent Job.
This procedure was written with:
This procedure applies to versions of Talend Open Studio for Data Integration starting from v4.2.3.
In this tutorial, you will create two Jobs: a parent Job and a child Job. The child Job will read data from a text file, populate the total number of rows and pass the rows to the parent Job.
The input file, named in.txt, is as follows:
id;name 1;Shong 2;Elise 3;Sabrina
Create a Job and name it childJob. It should look as in the following screenshot.
Note: The demo Jobs and the text file are also available in the attached Zip file.
Configure the tFileInputDelimited as in the following screenshot.
Configure the tFixedFlowInput as in the following screenshot.
Configure the tJavaRow as follows.
Type the following code into the Code box:
System.out.println("The total number of rows is:"+input_row.nb_line);
Execute the parentJob Job. The results are printed in the console:
Starting job parentJob at 14:37 16/06/2013. [statistics] connecting to socket on port 3801 [statistics] connected 1|Shong 2|Elise 3|Sabrina The total number of rows is:3 [statistics] disconnected Job parentJob ended at 14:37 16/06/2013. [exit code=0]
In this use case, you can see the importance of using a tBufferOutput component in a child Job to buffer records. The tRunJob reads the records from the buffer and transfers them to the next component.