Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm looking for implementing a retry mechanism for the tSalesforceConnection component, instead of having it failing (e.g. in case of Salesforce Remote Server temporary unavailable) and the Job going to terminate.
As the component raises an exception which breaks any outer loop, I was not able to develop and retry loop solution. Nevertheless, I might have missing something.
Any idea about a possible retry loop design for the tSalesforceConnection component?
A simple design as test:
Regards.
Hello,
We could use the tJavaflex component with the following code to enable the retry option for tsalesforcexxx component.
//begin
Exception lastException = null;
int i = 0;
for( ; i < 5 ;i++) {
try {
//main
//intentionally empty
//end
i = 10;
} catch (Exception e) {
lastException = e;
log.warn("Failed to connect, will retry after " + (i*2) + "seconds. Exception: " + e.getMessage() );
Thread.sleep(i*2*1000);
}
}
//we had an exception
if(i != 10) throw lastException;
Feel free to let us know if it helps.
Best regards
Sabrina
Hello,
We could use the tJavaflex component with the following code to enable the retry option for tsalesforcexxx component.
//begin
Exception lastException = null;
int i = 0;
for( ; i < 5 ;i++) {
try {
//main
//intentionally empty
//end
i = 10;
} catch (Exception e) {
lastException = e;
log.warn("Failed to connect, will retry after " + (i*2) + "seconds. Exception: " + e.getMessage() );
Thread.sleep(i*2*1000);
}
}
//we had an exception
if(i != 10) throw lastException;
Feel free to let us know if it helps.
Best regards
Sabrina
Hi @Xiaodi Shi
Thanks! The solution works very well, and I was succesfully able to catch the tSalesforceConnection exception and retry the connection multiple time.
Unfortunately, I have another issue.
I included the "Retrying Connection design" in a Joblet, in order to share it with several Jobs, but when I include the Joblet in a Job, that Job is aware and knows the connection, but it's unable to use it, which is quite weird to me.
For that reason, I'm creating a new post, here:
Joblet does not actually share a Salesforce Connection with its parent Job (talend.com)
Regards,
Lorenzo
Hello @Lorenzo Lucioni
We replied to your another topic about: Joblet does not actually share a Salesforce Connection with its parent Job.
Could you please have a look at it to see if it helps?
Best regards
Sabrina
Hi Sabrina,
saw your answer there, unfortunately it was not helpful, as it seems to me we are here facing a bug. That thread continues.
Thanks anyway for your support for this specific thread, the try/catch solution with the tJavaFlex component works very well.
The try/catch topic has been a critical topic on some of my Jobs... and wrapping everything valley of the tJavaFlex with that try/catch is very helpful.
Regards,
Lorenzo
Just for the records, my solution (with a wider use of Components, instead of Java code into the tJavaFlex Component):