concept dynamic router in category camel

appears as: dynamic router, Dynamic Router
Camel in Action

This is an excerpt from Manning's book Camel in Action.

Listing 5.10 Java bean deciding where the message should be routed next
public class DynamicRouterBean { public String route(String body, @Header(Exchange.SLIP_ENDPOINT) String previous) {      #1 return whereToGo(body, previous); } private String whereToGo(String body, String previous) { if (previous == null) { return "mock://a"; } else if ("mock://a".equals(previous)) { return "language://simple:Bye ${body}"; } else { return null;     #2 } } } #1 Previous endpoint URI #2 Ends Dynamic Router

As you can see in the whereToGo method, you use this fact and return different URIs depending on the previous step. When the dynamic router is to end, you return null ❷. It's very important that the Dynamic Router must return null at some point—otherwise, Camel will route the message forever.

Camel in Action

This is an excerpt from Manning's book Camel in Action.

As you can see in the whereToGo method, you use this fact and return different URIs depending on the previous step. When the dynamic router is to end, you return null .