Seven Stars

capture status code from subjob in main job

Hi,
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?
1 REPLY
Community Manager

Re: capture status code from subjob in main job

Hi  
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.
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business