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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

nested cMassegeRouter_1 component not working in a route

Hi all, 
I'm facing a problem that seems to my supervisor to, eventually, be a bug in TOS :-/, or maybe I'm just using the wrong components 0683p000009MACJ.png
 I wanted to  set a condition on the http verb, if it's a GET, then..., if it's a POST, then ... so I used a cMassegeRouter_1 component with the condition "${header." + org.apache.camel.Exchange.HTTP_METHOD + "} == 'GET'" , I had three "when" branches" and I had what I wanted, everything worked just fine (please see route1 attached bellow)
After that I put another cMessageRouter component in every when, so as to print a different message depending  on the HTTP response code, using the condition "${header." + org.apache.camel.Exchange.HTTP_RESPONSE_CODE + "} == 200 " (please see route2 attached below) 
Now my route behaves weirdly; exemple: 
when I run a DELETE request, the test is as follows:
-The route made me pass by the customer "Get", passes through the cMessageRouter_2, display a code "200 "  and then stops instead of making me pass by the branch "when2" which corresponds to a request "delete".
 The if / else nested does not work depending on the corresponding logic to the graph.The branch "when2" is called only when the two conditions "when4" and "when5" are false (dspite the fact that in my Rest Client, the http verb is "DELETE". 
When I looked into the code, it appers that it's a little bit messy: 

	from(uriMap.get("cHttp_3"))

.routeId("Base_cHttp_3")
.choice()
.id("cMessageRouter_1")
.when()
.simple("${header." + org.apache.camel.Exchange.HTTP_METHOD
+ "} == 'GET'")

.setHeader("CamelHttpMethod", constant("GET"))
.to(uriMap.get("cHttp_4"))

.id("cHttp_4")
.choice()
.id("cMessageRouter_2")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 200 ")
.log(org.apache.camel.LoggingLevel.INFO,
"chouetteRoute.cLog_1", "good")

.id("cLog_2")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 200 ")
.log(org.apache.camel.LoggingLevel.ERROR,
"chouetteRoute.cLog_1", "eRREUR")

.id("cLog_9")
.when()
.simple("${header." + org.apache.camel.Exchange.HTTP_METHOD
+ "} == 'POST'")
.log(org.apache.camel.LoggingLevel.ERROR,
"chouetteRoute.cLog_7",
"fhjjytyutttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt")

.id("cLog_7")
.setHeader("CamelHttpMethod", constant("POST"))
.setHeader("Content-Type", constant("application/json"))
.to(uriMap.get("cHttp_7"))

.id("cHttp_7")
.choice()
.id("cMessageRouter_4")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 200 ")
.log(org.apache.camel.LoggingLevel.INFO,
"chouetteRoute.cLog_1", "good")

.id("cLog_5")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 404 ")
.log(org.apache.camel.LoggingLevel.ERROR,
"chouetteRoute.cLog_1", "eRREUR")

.id("cLog_6")
.when()
.simple("${header." + org.apache.camel.Exchange.HTTP_METHOD
+ "} == 'DELETE'")

.setHeader("CamelHttpMethod", constant("DELETE"))
.to(uriMap.get("cHttp_1"))

.id("cHttp_1")
.choice()
.id("cMessageRouter_3")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 200 ")
.log(org.apache.camel.LoggingLevel.INFO,
"chouetteRoute.cLog_1", "good")

.id("cLog_3")
.when()
.simple("${header."
+ org.apache.camel.Exchange.HTTP_RESPONSE_CODE
+ "} == 404 ")
.log(org.apache.camel.LoggingLevel.ERROR,
"chouetteRoute.cLog_1", "eRREUR")

.id("cLog_4");
}



It's not clear which ".when(...)" is related to which ".choice()", and I think that that's what causes the weird behavior of my route. 
Thank you for your suggestions and your time. 
-Regards 
0683p000009MGe3.png 0683p000009MGda.png 0683p000009MGZ4.png 

Labels (2)
3 Replies
Anonymous
Not applicable
Author

* Sorry, I posted the same issue twice, I don't know how to delete one  0683p000009MPcz.png
Anonymous
Not applicable
Author

I thought about adding a "cStop"  component after the tLogs, but wit no result. 
Anonymous
Not applicable
Author

After some re-fresh-thinking,   I used the component "cSplitter"  so as to avoid the nested cMassegeRouter components. 
I managed to make only the "DELETE" working. 

0683p000009MGe8.png