Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4A10F200BA8 for ; Mon, 24 Oct 2016 22:38:49 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 46CE8160AEB; Mon, 24 Oct 2016 20:38:49 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 66B85160AD7 for ; Mon, 24 Oct 2016 22:38:48 +0200 (CEST) Received: (qmail 28516 invoked by uid 500); 24 Oct 2016 20:38:47 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 28503 invoked by uid 99); 24 Oct 2016 20:38:47 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Oct 2016 20:38:47 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 9CF34C0CA4 for ; Mon, 24 Oct 2016 20:38:46 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.442 X-Spam-Level: **** X-Spam-Status: No, score=4.442 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_REPLY=1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id dd36_T1DtZSD for ; Mon, 24 Oct 2016 20:38:44 +0000 (UTC) Received: from mail-qk0-f177.google.com (mail-qk0-f177.google.com [209.85.220.177]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 6CAF15F3A1 for ; Mon, 24 Oct 2016 20:38:44 +0000 (UTC) Received: by mail-qk0-f177.google.com with SMTP id v138so7817436qka.5 for ; Mon, 24 Oct 2016 13:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=C7hPjT4fOCyEuPK3rYpJz0i6yqfk3XuYVfZHXj/c8cQ=; b=kxAGxfENmMG29gw68UoTthVB0XDJXeaWDhI/C27F3pMeoo/8fbnz9AelwkaM1DhBBh SooGP2LLJnb+6z8YYItq+bodV/qWNvSI/O0LwUgn3pWKgph+yIh9NobW0Xd/wQOVuBDw aRQoLAE/eMly1HbWzfqhpuo56vDF356lCYP+ItUKPmtmEwxZPoTDOcTXDcHa/ziJk15k wrTLypNHJyXK+++E2QDeMm5SZBmLpTFozvixUsJUDUwJL82iW232X7pDZMLqQ0IW14OP Cxe/oSm5K5sGX776OKwe2NKqWonQJHbdufLXIE3YrlRj0vKJbqEJzGkaHW+XxCWE88IV V3Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=C7hPjT4fOCyEuPK3rYpJz0i6yqfk3XuYVfZHXj/c8cQ=; b=Ah82JQ5HX6b7xwZyBF1m7vW7ecE6+vAIgubsLckjOP5Jg6eNlMrP+mwLecUbotn7SL rZk97wnExNAKjqATd5HTJaW77lLi/49Vr3SA+jXWiLXg4diNJwkuGAFcDnh2pnmiudX+ 6FsnOG2nSb4YMSxm3cjIksHZ8WsQhfdxDNLCuUhSFe/eOGtVFZEdJD1BmVhsdI818DbQ GslFDf6h6YWf2gmZu71B3SV/nCiG69OVZaYogS7+R4BX8jqJsvfj6PU0Ykl5iV8inUZq boVys1zhnAy/z8h5BOMBffNVG7fYNyfEyAD9wQ4G/bekK/JOc5ZsC2S1QQdq5Mhp1ao7 WRyA== X-Gm-Message-State: ABUngvdFHiNesRTsq9fUK/3CxN/bq2N8BLTRbzpXyAK14QWhEtcMjpOCgkV4V5MnqLfn5VSzOcs/7hCR1SPgPQ== X-Received: by 10.55.180.2 with SMTP id d2mr14476553qkf.175.1477341523876; Mon, 24 Oct 2016 13:38:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.55.154 with HTTP; Mon, 24 Oct 2016 13:38:43 -0700 (PDT) In-Reply-To: References: <1477295302527-5789157.post@n5.nabble.com> <1477299791989-5789165.post@n5.nabble.com> <1477302770894-5789169.post@n5.nabble.com> <002201d22de5$cb5c24e0$62146ea0$@de> <1477314242157-5789179.post@n5.nabble.com> From: Steve973 Date: Mon, 24 Oct 2016 16:38:43 -0400 Message-ID: Subject: Re: AW: Dynamic routing based on collection values To: users@camel.apache.org Content-Type: multipart/alternative; boundary=94eb2c06fa2abe25b7053fa26083 archived-at: Mon, 24 Oct 2016 20:38:49 -0000 --94eb2c06fa2abe25b7053fa26083 Content-Type: text/plain; charset=UTF-8 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 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 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" > > 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> myMap){ > > > { > > > for (Map.Entry> 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 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.anthwar@gmail.com < > > > raghavender.anthwar@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. > > > > > > > > > > --94eb2c06fa2abe25b7053fa26083--