Using tDie in a subJob for handling a flow

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? 

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?
Community Manager

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.
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
Community Manager

Re: Using tDie in a subJob for handling a flow

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

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

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 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch