Search code examples
etltalend

Talend - load context to subjobs


I am trying to create a main job in Talend that would scan a directory for multiple files (f1.csv, f2.xls...)and then run a separate job created for the specific file. I would like to create a context variable that captures the filename and calls the appropriate job. How can I setup the context variable to store the filename of the found file and pass it to the other jobs?


Solution

  • Create a job called child_job. Inside, go to context tab, and create a new context variable called file with the type String. Inside, you can put components that references this context.file variable. Now, create another job called main_job. Inside it, put a tFileList. Configure the settings in this component with the desired path where you want to find the files. Then, drag the child_job from the left panel (job designs) or put a tRunJob and set it to call the child_job job. Finally, join the tFileList with the iterate link with the child_job, select the child_job, go to Component tab, add a parameter (the file parameter that you created before) and set the value to ((String)globalMap.get("tFileList_1_CURRENT_FILE")) and you are done!

    Something like that:

    enter image description here

    enter image description here

    enter image description here