Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 .
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