This is also one of those fuzzy areas where sometimes it is easier to simply pass the message body into a bean and then use ProducerTemplate instances to send values us different routes. Under normal circumstances I wouldn't do it that way as Camel does a great job of heavy lifting. But in some cases just using a Java bean is simpler and cleaner. Imagine having a CityRouteHandler with one method on it.
public void routeToCities(Map<String, List<String>> myMap){ { for (Map.Entry<String, List<String>> entry : map.entrySet()) { if("Hyderabad".equals(entry.getKey()){ for(String message: entry.getValue()) hyderabad.sendBody(message); ...etc. } } } You could then create a helper method as well that instead of looping inside for each new entry and sending to the producer template, have the helper method take the List<String> and producer template and loop inside it. That would simplify the map code. The ProducerTemplate entries in this class would be declared something like this: @InjectEndpoint(uri="direct:hyderabad") ProducerTemplate hyderabad; I've written this free hand so while the ideas are correct I can't vouch for the correctness of the code itself. On Mon, Oct 24, 2016 at 8:04 AM, raghavender.anth...@gmail.com < raghavender.anth...@gmail.com> wrote: > Thanks a lot for the response. This seems like useful, I'll give out a try > and will update you accordingly. > > Best, > Raghavender Anthwar > > > > -- > View this message in context: http://camel.465427.n5.nabble. > com/Dynamic-routing-based-on-collection-values-tp5789157p5789179.html > Sent from the Camel - Users mailing list archive at Nabble.com. >