How do I use ConsumerTemplate?

This is my attempt. Created a new Processor:

// Dequeue
.when(and(header("CamelHttpUri").regex(".*/my-queue.*"), 
header("CamelHttpMethod").isEqualTo("GET")))
        .setExchangePattern(ExchangePattern.InOut)
        .process(new InOutProcessor())

And inside it I do this:
    
private class InOutProcessor implements Processor {     
        private ConsumerTemplate consumer;
        
        public void process(Exchange exchange) throws Exception {
                exchange.getIn().setHeader("Content-Type", 
constant("application/xml"));         
                consumer.receiveBody("my-queue-endpoint ");
        }
    }

But the consumer I created is allways null and returns a NullPointer. How do I 
initialize it?

I also didn't understand what you ment whet saying I could use two inOnly 
routes instead of one InOut. Can you give me and examples?

Best regards,
Carlos Figueiredo

-----Original Message-----
From: Christian Müller [mailto:christian.muel...@gmail.com] 
Sent: sexta-feira, 18 de Novembro de 2011 18:39
To: users@camel.apache.org
Subject: Re: Queue/Dequeue perfomance InOut ExchangePattern

If you use an embedded broker, you should consider using the VM
(vm://brokerName) protocol instead of TCP (tcp://localhost:61616). But this
has nothing to do with your issue... ;-)

If you have to achieve high throughput, you should consider using async
messaging (two inOnly routes instead of one InOut). But that's what you
do...

What's about using the ConsumerTemplate to receive messages instead the
PollConsumer? It sounds more correct for me, because you only want to
return one messages as I understood your route...

Best,
Christian

Reply via email to