capture status code from subjob in main job

Eight Stars

capture status code from subjob in main job

I am developing a job which calls numerous subjobs.
I have added the tLogCatcher component in each of the subjob and main job.
The basic purpose behind adding the component in all jobs is to catch any error/exception at its origin and propagate it through the hierarchy correctly.
Now the catch is that every time an exception occurs, the main job should not terminate.
The main job should terminate only in case the exception in the subjob is of severe category such as database not available or network connectivity lost.
If there are other exceptions such as error while reading a file or writing to a file, the subjob performing the said action should fail but the main job should continue with the execution.
For this I disabled the "Die on child error" checkbox in the tRunJob component that invokes the subjob.
But now I want to check why the subjob failed and accordingly take appropriate actions in the main job.
For this I am thinking of creating a context variable called job_status_code that is initially set to 0 at the start of the subjob execution.
This variable will be set to another numeric value in case the job fails after the execution of the tLogCatcher component.
I created a test job to check if this logic works, unfortunately it does not.
Here is the screenshot of the main job:
And this is the subjob
When I execute the main job, I see that the context variable job_status_code is updated through the tLogCatcher component.
But when I check for the value of the context variable in the main job I see it as null.
Can anyone tell me why this is happening? And what I can do to pass the job status value to the main job when an error occurs?
Community Manager

Re: capture status code from subjob in main job

You are able to pass the status code of child job to main job. Make sure you have defined the same schema on tRunJob as tBufferOutput component.
Talend | Data Agility for Modern Business


Talend named a Leader.

Get your copy


Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables


Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema


Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables