Hi

I have a camel REST endpoint which receives a request of the form:-

{"method" : "getHello"}

Based on the value in the method field in the request body I want to route
the request to different routes. So I tried something like this below:-

from("jetty:http://localhost:8888/hello";).unmarshal().json(JsonLibrary.
Jackson, RouteRequest.class)

.choice()

.when(method(DynamicRouter.class, "route").isEqualTo("getHello")).to(
"stream:out")

.otherwise()

.log("Processing Failed");


Dynamic Router class is like below:-


public class DynamicRouter {

public String route(RouteRequest req) {

switch (req.getMethod()) {

case "getHello":

return "xxxx";

}

return null;

}

}


Even though I am returning xxxx from route() but the below Predicate is
always evaluating to true and it is never going to .otherwise


isEqualTo("getHello")).to("stream:out")


Can someone let me know what I am doing wrong?


Thanks,

Reply via email to