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 <claus.ib...@gmail.com> 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
> <jagannath.na...@fosteringlinux.com> 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 <claus.ib...@gmail.com> 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
> >> <jagannath.na...@fosteringlinux.com> wrote:
> >> > Thank you fabrizio.
> >> >
> >> > But the issue is with passing dynamic uri to pollenrich.
> >> >
> >> > On 25 March 2016 at 13:25, fabrizio.spataro <
> fabrizio.spat...@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
> >> > <route>
> >> >   <from uri="direct:start"/>
> >> >   <pollEnrich>
> >> >     <simple>seda:${header.name}</simple>
> >> >   </pollEnrich>
> >> >   <to uri="direct:result"/>
> >> > </route>
> >> >
> >> > But I am restricted to use 2.15 only
> >> >
> >> > example here: http://camel.apache.org/recipient-list.html
> >> >>
> >> >> I want to replace this line
> >> >
> >> >         <pollEnrich uri="activemq:queue:SECOND?selector=head='jagan'"
> >> > strategyRef="myStrat" timeout="30000"/>
> >> >
> >> > With something like this
> >> >
> >> >         <pollEnrich
> 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

Reply via email to