How to Retry Salesforce Connection n times on Error

One Star

How to Retry Salesforce Connection n times on Error

Hello Talend Users/Team,
I have a requirement to try n number of times to connect to Salesforce.
If the connection fails first time then try 5 time( n times) to see if connection works. If not let the Job Error out.
Here is the description...
I have couple of Salesforce Input and output component. I want to use just 1 Salesforce connection instance and use that for all the salesforce input/output component.
I am able to do this by using a Salesforce connection Component first and then use the same connection in all the salesforce input/output component.
But I have another requirement " If the connection fails for the first time I need to retry for 5 times and see if it connect.
I am not able to find out how this can be implemented.
I saw TLoop, tforloop. - but all these does not seem to help in this scenario.
Please can any one guide me if you have come across such scenario..
Thanks,
Ravi
Community Manager

Re: How to Retry Salesforce Connection n times on Error

Hi Ravi
Here is an scenario base on your requirement, it retry 5 times with tLoop component if the connection is failed.
Code on tJavaRow:
if(input_row.errorCode==0){
context.isContinue=false;
}else if(input_row.errorCode==1&&
((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION"))<5){
context.isContinue=true;
}else{
context.isContinue=false;
}

For more information, please my screenshots.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Highlighted
One Star

Re: How to Retry Salesforce Connection n times on Error

Can you load the screenshots and clarify how components are set-up? Pushing a job to a server where tSalesforceConnection timeouts out consistently, so need this loop to ensure job completes.
Many thanks
Community Manager

Re: How to Retry Salesforce Connection n times on Error

Hi frank.conroy1223
This topic was a little old, and I did't save the job. However, the job design looks like:
main job;
tloop--iterate--tRunjob--main--tJavaRow
tRunJob: call the child job, uncheck the 'die on child job error' box. 
on tJavaRow:
if(input_row.errorCode==0){
context.isContinue=false;
}else if(input_row.errorCode==1&&
((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION"))<5){
context.isContinue=true;
}else{
context.isContinue=false;
}

child job:
tSalesforceConnectiion--oncomponenterror--tFixedFlowInput1--main--tBufferOutput1
   |
onsubjobok
   |
your main business processing
  |
onsubjobok
  |
tFixedFlowInput2--main--tBufferOutput2
on tFixedFlowInput1: define one column called errorCode, int/Integer type, set its value as 1.
on tFixedFlowInput2: define one column called errorCode, int/Integer type, set its value as 0.
Hope this helps you!
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: How to Retry Salesforce Connection n times on Error

hi ,
where is context.isContinue being used??
Community Manager

Re: How to Retry Salesforce Connection n times on Error

hi ,
where is context.isContinue being used??

isContinue is a context variable with boolean type, it is used in Condition filed on tLoop component (While type).
----------------------------------------------------------
Talend | Data Agility for Modern Business

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