One Star

Using tDie in a subJob for handling a flow

Hi everyone,
I'm new in Talend, and I'm working with a Main Job and Sub Jobs... in the Sub Jobs I'm using tDie to exit in specific events, and I want to use that to redirect the execution in the Main Job as an IF sentence.
An example:
Main Job: 
   Run subJob1: 
   -(on subjobOK)-> Run subJob2
   -(on subJobError)-> tDie
subJob1:
   - CheckFileOnFTP:
      -(IF Exist)-> Load into DB
      -(IF Not Exist)-> tDie
So, when I run de Main Job and the file in the FTP doesn't exist, I get a Java Error... even when I handle the existance of the file with tDie. And if I run only the subJob, the error-handle works fine.
How can I handle this kind of 'exceptions' with Talend? 

7 REPLIES
Seventeen Stars

Re: Using tDie in a subJob for handling a flow

If you do want to steer the job chain based on the return code:
1. uncheck the option in the tRunJob Die On Error.
2. If the if-trigger and use here the tRunJob return value CHILD_RETURNCODE (Integer) to decide which tRunJob should called next.
One Star

Re: Using tDie in a subJob for handling a flow

Thank you Jan,
Works fine Smiley Wink, now I can handle our own return codes in order to be more specific about the messages of ending jobs.
But if I use a tPostjob, it will override the Return Code of any tDie and return 1, even when I put a tLogCatcher on the tPostjob.
So, how can I get my return codes from a Child Job who have tPostjob?
Fifteen Stars

Re: Using tDie in a subJob for handling a flow

Hi JSeverino,
I raised a Talend Jira about this bug and they claimed it is not a bug. Apparently it is perfectly acceptable for a tDie error code not to be returned to the parent job IF the child job uses a tPostJob. My reaction to that is.....probably not appropriate to be written here. However, I wrote some code which provides a workaround to this. It is described in the Jira which is here: https://jira.talendforge.org/browse/TDI-36963
If you agree that this needs fixing, please comment on the Jira.
Rilhia Solutions
Seventeen Stars

Re: Using tDie in a subJob for handling a flow

Hi, indeed it is a bit weird behaviour the error code does not survive a tPostJob processing. Because if that, I usually have following procedure:
I always inspect the globalMap for keys ending with ERROR_MESSAGE and DIE_CODE and take this value as real exist code by setting the member variable this.errorCode.
One Star

Re: Using tDie in a subJob for handling a flow

Hi Richard.
Thanks for answer. 
I'm agree. I use tPostjob for logging status, so I need to keep the final status (in this case given by the tDie component)...
By the moment I'll avoid the use of tPostjob.. that's sad because I think is a very useful component Smiley Sad
One Star

Re: Using tDie in a subJob for handling a flow

Thanks Jan,
Your prodecure sounds like the way we must handle this.
Smiley Wink
Fifteen Stars

Re: Using tDie in a subJob for handling a flow

That is what the code I posted in the Jira does.
Rilhia Solutions