Could you try:
String username = exchange.getIn().getHeader(USERNAME_TOKEN, String.class);
String password = exchange.getIn().getHeader(PASSWORD_TOKEN, String.class);

Best,
Christian


On Mon, Sep 24, 2012 at 4:40 PM, anupamsen <anupam...@yahoo.com> wrote:

> Hi,
>
> I have a route somewhat like below -
>
> <route id="periodicallyPolledInputQueueHandlerRoute">
>   <from
> uri="quartz://periodicallyPolledInputQueueHandler?cron=0+0/5+*+*+*+?"/>
>   <camel:transacted ref="PROPAGATION_REQUIRED_XL"/>
>   <pollEnrich
>
> uri="jms:queue:JMS-Server/periodicallyPolledInputQueue?disableReplyTo=true"/>
>   <process ref="periodicallyPolledInputHandler" />
> </route>
>
> the periodicallyPolledInputHandler is a Processor that has the following
> definition for the process function -
>
> public void process(Exchange exchange) {
>   /**
>    * Try getting it from the exchange header
>    */
>   Map headers = new HashMap();
>
>   String username =
> (String)exchange.getIn().getHeaders().get(USERNAME_TOKEN);
>   String password =
> (String)exchange.getIn().getHeaders().get(PASSWORD_TOKEN);
>   String ackId = (String)exchange.getIn().getHeaders().get(ACK_ID);
>
>   headers.put(USERNAME_TOKEN, username);
>   headers.put(PASSWORD_TOKEN, password);
>   headers.put(ACK_ID, ackId);
>
>   String originalConsumer =
> (String)exchange.getIn().getHeaders().get(ORIGINAL_CONSUMER_TOKEN);
>   if(null != originalConsumer)
>   {
>     CamelContext context = new DefaultCamelContext();
>     context.addComponent("jms", jmsComponent);
>     ProducerTemplate template = context.createProducerTemplate();
>     template.setDefaultEndpointUri(originalConsumer);
>     template.sendBodyAndHeader(originalConsumer, ExchangePattern.InOnly ,
> exchange.getIn().getBody(String.class), headers);
>   }
> }
>
> What I am trying to achieve here is in case the originalConsumer is unable
> to reach the respective service it pushes the message to
> "JMS-Server/periodicallyPolledInputQueue". Further I am trying to poll the
> same queue every 5 minutes and push all the messages to the main consumer
> which is represented by a URI stored in the header originalConsumer.
>
> The issue that I am facing is, the headers set on the process method is not
> propagated to the original consumer. I do the following to get the header
> tokens -
>
> String username =
> (String)exchange.getIn().getHeaders().get(USERNAME_TOKEN);
> String password =
> (String)exchange.getIn().getHeaders().get(PASSWORD_TOKEN);
>
> Even if I print the In headers these are not printed.
>
> Not sure whats happening here. Help in this regard will be highly
> appreciated.
>
> Thanks.
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Header-goes-missing-while-posting-from-a-periodically-polled-consumer-tp5719860.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--

Reply via email to