Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1DA0C18CE6 for ; Sat, 26 Mar 2016 05:03:20 +0000 (UTC) Received: (qmail 58602 invoked by uid 500); 26 Mar 2016 05:03:19 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 58529 invoked by uid 500); 26 Mar 2016 05:03:19 -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 58517 invoked by uid 99); 26 Mar 2016 05:03:18 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 Mar 2016 05:03:18 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 871F3180526 for ; Sat, 26 Mar 2016 05:03:18 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.362 X-Spam-Level: *** X-Spam-Status: No, score=3.362 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, KAM_INFOUSMEBIZ=0.75, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=fosteringlinux-com.20150623.gappssmtp.com Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id h92xCTVe1CPI for ; Sat, 26 Mar 2016 05:03:16 +0000 (UTC) Received: from mail-qk0-f176.google.com (mail-qk0-f176.google.com [209.85.220.176]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 5AADE5F235 for ; Sat, 26 Mar 2016 05:03:15 +0000 (UTC) Received: by mail-qk0-f176.google.com with SMTP id s5so49589832qkd.0 for ; Fri, 25 Mar 2016 22:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fosteringlinux-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=J64SV1Qlm0+8gAjAopXd9/ynlI9SfHdz5bcbKK5qK5A=; b=eJrQH3tyVmQ0wIQ1O1F12ydKxWJcQCxo8SOxK2fxAhX9Qtvs47KuJPmCGeuuc9RQgK 8t3vLyloiDLgimu7XPXC4UdoybpRfjBkv6mtEUw07A6sF5Sr42V026D3E7RSYVNEOkSg KTkw9EUzhuO3LQ3vFibJMRpbAOSmGnABGvoSVU/oHxaclr5GDByLPIUXRCYRRqzHxJmj sUuyEYrcKK60xgUloZ6u2CosjRoAIbiWjIaN9u4HVAWRX3NbS+VSKveGohQkK0+im/B+ xhOSPexmdSCo+Gn0TcctWrqkcSajc1lw9t0UWtgwxW8xNet7hw1j4RRwGWwK/Srwtx1X yKxg== 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:date :message-id:subject:from:to; bh=J64SV1Qlm0+8gAjAopXd9/ynlI9SfHdz5bcbKK5qK5A=; b=iYPkVm1pjUxxyECqNgWWqzteVu/HbS3ypp1kP7cJwOkQVwHRpNCF2TsMC60eGgTB13 KBb/EzQnWivau4jdZVxmpVxecqkKOEINO6KsPuZ6MraDNmFhhhnSLNcPWemhDMWvDHBT KInb1AZPhglr3Y+LeZqyL2RqotfSLKqnXGAA2Ua2sgvsrN8lNM7UkuzTnEFMBDq/Jk4x l+bFafOaMCpmQsxNWTDa77H+t3n37/McTXjsHqn1szBccxI/0TPsAsNJQTauduoweJle Hipqt8G4KgKnqDZxIvaudBs1AIYl/cZeFboyIJWzTCYWD+YwyyK/BE+aotkQQQp0fFFs aUTw== X-Gm-Message-State: AD7BkJKesNkRiJ4NypifKS20ZRFT/Ei14y61eQsq8e98IlmqrPxQMVD0lJX/lmO4QsLH5Prpm9N1/4FpqfIy3w== MIME-Version: 1.0 X-Received: by 10.129.95.9 with SMTP id t9mr8867970ywb.94.1458968594326; Fri, 25 Mar 2016 22:03:14 -0700 (PDT) Received: by 10.37.50.75 with HTTP; Fri, 25 Mar 2016 22:03:14 -0700 (PDT) In-Reply-To: References: <1458892529697-5779690.post@n5.nabble.com> Date: Sat, 26 Mar 2016 10:33:14 +0530 Message-ID: Subject: Re: Issue with dynamic uri From: Jagannath Naidu To: users@camel.apache.org Content-Type: multipart/alternative; boundary=001a1147e8c0cdf323052eec989c --001a1147e8c0cdf323052eec989c Content-Type: text/plain; charset=UTF-8 Hi Claus, !!@#$@ it worked :-D. Thank you very much Below is what I am using. Logger log = Logger.getLogger(JettyRoute.class.getName()); DynamicPollEnricher pollEnricher = new DynamicPollEnricher(); public String process(Exchange exchange) throws Exception { log.info("START"); // TODO Auto-generated method stub ConsumerTemplate consumerTemplate = exchange.getContext().createConsumerTemplate(); String headVal = (String)exchange.getIn().getHeader("dynamic"); String enrichURI = "activemq:queue:SECOND?selector=head='"+headVal+"'"; log.info("HELOO " + headVal + " H " + enrichURI); /*ExchangeHelper.*/ Exchange answer = consumerTemplate.receive(enrichURI, 20000); log.info("Received Exchange Body: "+answer.getIn().getBody(String.class)); log.info("Received Exchange MessageId: "+answer.getIn().getMessageId()); String a = answer.getIn().getBody(String.class); return a; } On 25 March 2016 at 19:10, Claus Ibsen wrote: > You can use a processor (or bean) - the code below is pseudo written > in the email > > process(Exchange exchange) { > // use simple to build the dynamic uri > String uri = > exchange.getContext().resolveLanguage("simple").evaluate("activemq:queue:SECOND?selector=${header.head}", > String.class); > > // create polling consumer to poll the message > PollingConsumer pc = exchange.getEndpoint(uri).createPollingConsumer(); > pc.start(); > try { > Exchange out = pc.receive(30000); > if (out != null) { > .. merge from out into current exchange > Object newBody = out.getIn().getBody(); > Object oldBody = exchange.getIn().getBody(); > .. merge like you want to do in that strategy class. > .. or you can use the strategy here > // done out > out.getUnitOfWork().done(out); > } finally { > pc.stop(); > } > > On Fri, Mar 25, 2016 at 9:24 AM, Jagannath Naidu > wrote: > > Thanks Claus, > > > > I came here for help after reading this link > > > http://camel.465427.n5.nabble.com/pollEnrich-consumer-with-selector-td4939908.html > > . > > And I am fairly new to camel, would you mind sharing some/any sample code > > for this. > > Thank you very much. > > > > On 25 March 2016 at 13:35, Claus Ibsen wrote: > > > >> If you are stuck on Camel 2.15.x you would need to write some java > >> code where you build the uri and use a consumer template to poll. And > >> do the enrichment from the java code. > >> > >> > >> > >> On Fri, Mar 25, 2016 at 9:02 AM, Jagannath Naidu > >> wrote: > >> > Thank you fabrizio. > >> > > >> > But the issue is with passing dynamic uri to pollenrich. > >> > > >> > On 25 March 2016 at 13:25, fabrizio.spataro < > fabrizio.spataro@bizmate.it > >> > > >> > wrote: > >> > > >> >> Hello, > >> >> > >> >> abstractly dynamic uri can be do it using recipientList + simple > >> leanguage > >> >> > >> >> > >> > http://camel.apache.org/content-enricher.html > >> > says, you can use something like > >> > > >> > > >> > > >> > seda:${header.name} > >> > > >> > > >> > > >> > > >> > But I am restricted to use 2.15 only > >> > > >> > example here: http://camel.apache.org/recipient-list.html > >> >> > >> >> I want to replace this line > >> > > >> > >> > strategyRef="myStrat" timeout="30000"/> > >> > > >> > With something like this > >> > > >> > uri="activemq:queue:SECOND?selector=${header.head}" > >> > strategyRef="myStrat" timeout="30000"/> > >> > > >> > > >> > http://camel.465427.n5.nabble.com/pollEnrich-consumer-with-selector-td4939908.html > >> > says it is possible with an alternative, but I am still clueless. I am > >> > fairly new to camel usage. > >> > > >> > > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> -- > >> >> View this message in context: > >> >> > >> > http://camel.465427.n5.nabble.com/Issue-with-dynamic-uri-tp5779689p5779690.html > >> >> Sent from the Camel - Users mailing list archive at Nabble.com. > >> >> > >> > > >> > > >> > > >> > -- > >> > Thanks & Regards > >> > > >> > B Jagannath > >> > Keen & Able Computers Pvt. Ltd. > >> > +919871324006 > >> > >> > >> > >> -- > >> Claus Ibsen > >> ----------------- > >> http://davsclaus.com @davsclaus > >> Camel in Action 2: https://www.manning.com/ibsen2 > >> > > > > > > > > -- > > Thanks & Regards > > > > B Jagannath > > Keen & Able Computers Pvt. Ltd. > > +919871324006 > > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 > -- Thanks & Regards B Jagannath Keen & Able Computers Pvt. Ltd. +919871324006 --001a1147e8c0cdf323052eec989c--