Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
cjiawei
Contributor II
Contributor II

tRestClient Only Run IF there the tLoop1 if there is an Response and Iterate if there is an error

Hi,

I am trying to only run the tLoop_1 if there is a successful response from tRestClient5.

0695b00000rdlJKAAY.png

Would kindly seek help in this. I have tried to search online for the solution and implemented the tJavaFlex but it seems to still not work.

tJavaFlex settings is as stated below :

0695b00000rdlKwAAI.png

Have tried to put (Boolean.TRUE.equals(globalMap.get(

"RestFailure"

))) as my Run If criteria but still failed. It ended up indicating true even when the tRestClient_5 didn't manage to get any results.

Appreciate any help on this... thanks!

Labels (2)
1 Solution

Accepted Solutions
OFlores1699434353
Contributor
Contributor

To achieve the desired behavior in Talend, where the tRestClient only runs if there is a tLoop1 response and iterates if there is an error, you can follow these steps:

 

1. Set up the tLoop1 component to iterate a certain number of times or until a certain condition is met. You can use a tJava component to set up the loop and define the exit condition based on the error/exit code of the tRestClient component[3].

USPayServ Loginn 2. Connect the tRestClient component to the tLoop1 component. This will ensure that the tRestClient only runs if there is a response from the tLoop1 component.

 

3. Set up error handling for the tRestClient component using a tJava component. If the tRestClient component encounters an error, the tJava component will catch the error and allow the tLoop1 component to iterate again[2].

 

4. If you want to log the error message, you can use a tLogCatcher component to catch the error message and send it to a log file or database[5].

 

Overall, the key is to use the tLoop1 component to control the iteration and error handling, and to connect the tRestClient component to the tLoop1 component to ensure that it only runs when there is a response.

 

 

View solution in original post

3 Replies
Anonymous
Not applicable

Hi

Could you please explain this behavior? "when the tRestClient_5 didn't manage to get any results"

tRestCliend fails to call the API and has an exception error or the API call is successfully, but no data is returned in response?

 

Regards

Shong

OFlores1699434353
Contributor
Contributor

To achieve the desired behavior in Talend, where the tRestClient only runs if there is a tLoop1 response and iterates if there is an error, you can follow these steps:

 

1. Set up the tLoop1 component to iterate a certain number of times or until a certain condition is met. You can use a tJava component to set up the loop and define the exit condition based on the error/exit code of the tRestClient component[3].

USPayServ Loginn 2. Connect the tRestClient component to the tLoop1 component. This will ensure that the tRestClient only runs if there is a response from the tLoop1 component.

 

3. Set up error handling for the tRestClient component using a tJava component. If the tRestClient component encounters an error, the tJava component will catch the error and allow the tLoop1 component to iterate again[2].

 

4. If you want to log the error message, you can use a tLogCatcher component to catch the error message and send it to a log file or database[5].

 

Overall, the key is to use the tLoop1 component to control the iteration and error handling, and to connect the tRestClient component to the tLoop1 component to ensure that it only runs when there is a response.

 

 

cjiawei
Contributor II
Contributor II
Author

Thanks for the follow up on this. But yes I have proceeded to create a condition that breaks the loop if tRestClient response is an error. Thanks a lot!