Four Stars

Job retry mechanism in case of DB connection failure in Talend

Hi Guys,

I have a requirement in which I extract data from files and databases as source into target databases (mostly oracle).

But sometimes job fails because of some db connection errors like "Connection timed out" and "network adapter could not establish connection" like these. when such issues arise I would like the job to retry to connect again and again(for fixed number of times) until there is successful connection.

So can anyone help me on how can I achieve this instead of running the job manually when these errors occur?

 

Quick reply would be appreciated.

Thanks in advance.

10 REPLIES
Ten Stars

Re: Job retry mechanism in case of DB connection failure in Talend

if it's for 3 time, just add a parent jab calling 3 times your job link subjobs with on subjobError.

Francois Denis

Don't forget to tag when it's "solved"!

Four Stars

Re: Job retry mechanism in case of DB connection failure in Talend

Hi,

Sorry I didn't get you. Could you please elaborate if possible??

 

Ten Stars

Re: Job retry mechanism in case of DB connection failure in Talend

open a new job
add tRunJob calling your job with oracle db connection ….
add an other trunjob calling your calling your job with oracle db connection ….
link first and second trunjob with an onSubjobError.
that's all.

Francois Denis

Don't forget to tag when it's "solved"!

Four Stars

Re: Job retry mechanism in case of DB connection failure in Talend

Hi,

PFA screenshot.

Is this the approach you are speaking about??

But I want the job to retry on its own for multiple times until the connection gets established.

Please correct me if i'm wrong on my requirement.

Ten Stars

Re: Job retry mechanism in case of DB connection failure in Talend

I just say if it's for 3 times.
an other way is to make an infinit loop tloop with always false exit condition.
with a tDie on an onSubjodOk link.

Francois Denis

Don't forget to tag when it's "solved"!

Four Stars

Re: Job retry mechanism in case of DB connection failure in Talend

Hi ,

I have tried to implement the solution using tLoop

PFA screenshot.

 code in tLoop(while loop) :  i<=10 && context.status == false

I intentionally made the job to fail with connection error but still its making only 1 attempt instead of 10

which is defined in the loop.

tJava : im resetting the context.status = true if conn is fine.

Ten Stars

Re: Job retry mechanism in case of DB connection failure in Talend

you have to link tloop with trunJob or to add a tlogCatcher to still run after the error.

Francois Denis

Don't forget to tag when it's "solved"!

Four Stars

Re: Job retry mechanism in case of DB connection failure in Talend

Yes I have tried connecting the tLoop to tRun job which has the main connection check.

but after that how to proceed?

 

PFA screenshot.

 

It would be great if you have any sample job designed so that it will be easy for me.

Ten Stars

Re: Job retry mechanism in case of DB connection failure in Talend

set tLoop for 10 loop.
add the onSubjobOk to tDie.

Francois Denis

Don't forget to tag when it's "solved"!

Four Stars

Re: Job retry mechanism in case of DB connection failure in Talend

Hi Guys,

Finally I was able to prepare the proper job for DB connection retry mechanism.

PFA screenshots of parent job and child job.

Please let me know if anyone have any doubts on this

Parent job flow :  tLoop -----> tRunJob -----> tJavaRow

 

tLoop code (use while loop) : context.status (status is a boolean context variable with default value as true

tJavaRow : 

                      if(row1.errorCode==0){
                      context.status=false;
                     }else if(row1.errorCode==1&&
                    ((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION"))<15){
                    context.status=true;
                    Thread.sleep(5*1000);
                    }else{
                    context.status=false;

 

PFA screenshots for both the jobs and let me know for any queries