Five Stars

ESB: REST service return empty items instead of 404

Hello,

 

I have design an ESB module for REST services. My ESB is developed as follows (see attachement):

 

tPostgresqlConnection -> RestInterface -> tFlowtoIterate -> tPostgresInput -> tXMLMap -> tRestresponse

 

The REST service works good. But if the SQL query under tPostgresInput have no response the REST service return an 404. It is possibly to return an empty JSONS (for example {items:{}}) ? 

 

Greets 

 

Benjamin

 

 

 

  • ESB
Tags (4)
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: ESB: REST service return empty items instead of 404

Hello
You can check the number of lines are read from tPostGresInput and generate different response, for example:
tPostgresqlConnection -> RestInterface -> tFlowtoIterate -> tPostgresInput ->

tHashOutput-- runif1--thashinput--tXMLMap 1-> tRestresponse1
                    --runIf2--tfixedFlowInput--tXMLMap2--trestresponse2
thashoutput: cache the query data into memory.
thashinput: read the data from memory.

set the condition of runif1 as:
((Integer)globalMap.get("tPostgresqlInput_1_NB_LINE"))>0

set teh condition of runif2 as:
((Integer)globalMap.get("tPostgresqlInput_1_NB_LINE"))==0

tfixedFlowInput: you can customize the response string such as : "no data found" and assign it to output Document on tXMLMap2.

Regards
Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business
2 REPLIES
Community Manager

Re: ESB: REST service return empty items instead of 404

Hello
You can check the number of lines are read from tPostGresInput and generate different response, for example:
tPostgresqlConnection -> RestInterface -> tFlowtoIterate -> tPostgresInput ->

tHashOutput-- runif1--thashinput--tXMLMap 1-> tRestresponse1
                    --runIf2--tfixedFlowInput--tXMLMap2--trestresponse2
thashoutput: cache the query data into memory.
thashinput: read the data from memory.

set the condition of runif1 as:
((Integer)globalMap.get("tPostgresqlInput_1_NB_LINE"))>0

set teh condition of runif2 as:
((Integer)globalMap.get("tPostgresqlInput_1_NB_LINE"))==0

tfixedFlowInput: you can customize the response string such as : "no data found" and assign it to output Document on tXMLMap2.

Regards
Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: ESB: REST service return empty items instead of 404

thx I will try it.