And, by default, that is a lot of threads that are not needed for his use case. Though I am not sure how many threads are created vs used when you are doing a recipient list and a splitter.
On Mon, Oct 24, 2016 at 2:51 PM, Brad Johnson <brad.john...@mediadriver.com> wrote: > How many producer templates would be produced? There's only a single > handler instantiated so if there are 5 routes that's 5 producer templates. > > On Mon, Oct 24, 2016 at 1:32 PM, Steve973 <steve...@gmail.com> wrote: > > > I'd worry about the overhead of creating so many producer templates. I > > would probably set a header that contains a map of keys to destinations, > > then you could set a recipient list of one endpoint that contains the > value > > at that key. Maybe brad's method isn't as overhead intensive because the > > template is injected, but this is more manual implementation than i would > > prefer. > > > > On Oct 24, 2016 9:21 AM, "Brad Johnson" <brad.john...@mediadriver.com> > > wrote: > > > > > 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. > > > > > > > > > >