Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello. I have a simple REST API that has 2 main responses. A response for a record found (200) and a response when no records are found (490). I can't get the 490 response to trigger. The 200 works when the DBInput returns results.
Instead of getting a 490, I get a 404 (which I don't program). I think this suggests the application just fails after the query or at the map flow.
What kind of logic / componenets should I have in place to handle flows when no results are returned from the query?
Some screenshots are below to show what I have in place for logic.
Hi
If there is no records, the components after tOracleInput will not be triggered. The workaround is to query the data and cache the into memory, and use runIf connector to trigger different subjobs.
eg:
.....tOracleInput1--main--tHashOutput1--runif1-->tHashInput1--tMap1--tRestResponse1
*********************************************** --runIf2-->tfixedFlowInput--tMap2--tRestResponse2
Set the condition of runIf1 as:
((Integer)globalMap.get("tDBInput_1_NB_LINE"))>0
Set the condition of runIf2 as:
((Integer)globalMap.get("tDBInput_1_NB_LINE"))=0
tfixedFlowInput: define the customized message and map it on tMap2.
Please try and let me know if you any questions.
Regards
Shong
Hi
If there is no records, the components after tOracleInput will not be triggered. The workaround is to query the data and cache the into memory, and use runIf connector to trigger different subjobs.
eg:
.....tOracleInput1--main--tHashOutput1--runif1-->tHashInput1--tMap1--tRestResponse1
*********************************************** --runIf2-->tfixedFlowInput--tMap2--tRestResponse2
Set the condition of runIf1 as:
((Integer)globalMap.get("tDBInput_1_NB_LINE"))>0
Set the condition of runIf2 as:
((Integer)globalMap.get("tDBInput_1_NB_LINE"))=0
tfixedFlowInput: define the customized message and map it on tMap2.
Please try and let me know if you any questions.
Regards
Shong
I appreciate the information and advice you have shared.
Hey @Shicong Hong ! Thank you for the reply. This solution sounds promising. I'm a little confused still because I am not what components I should be using after the run-if statments. The options seem very limited. (see below). Could I ask for a little more direction on that please?
I have gave an example job in my previous post, if you don't find tHashxxx component, please refer to this page to learn how show them.
Regards
Shong
Thanks. I was able to find the tHash with that link!
There seems to be an issue though with the logic used in the first if statement. I can't seem to make that work. Does anything jump out to you in these screenshots?
I appreciate the help. I'm still very new to Talend.
I found these small syntax changes worked. I removed extra brackets, and changed the arythmatic logic slightly.
(Integer)globalMap.get("tDBInput_1_NB_LINE")>=1
(Integer)globalMap.get("tDBInput_1_NB_LINE")<=0