Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Labels (3)
5 Replies
Anonymous
Not applicable
Author

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
_AnonymousUser
Specialist III
Specialist III

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
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

hi ,
where is context.isContinue being used??
Anonymous
Not applicable
Author

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).