I managed to get the ConsumerTemplate working like this:

    private class InOutProcessor implements Processor {         
        public void process(Exchange exchange) throws Exception {               
                
exchange.setIn(getContext().createConsumerTemplate().receive("activemq:queue:my-queue",2000).getIn());
                exchange.getIn().setHeader("Content-Type", 
constant("application/xml"));
        }
    }

But in terms of performance, it stayed nearly the same.

Also with VM instead of TCP the results where the same.

What did you meant with two inOnly routes instead of one InOut?

-----Original Message-----
From: Claus Ibsen [mailto:claus.ib...@gmail.com] 
Sent: terça-feira, 22 de Novembro de 2011 15:12
To: users@camel.apache.org
Subject: Re: Queue/Dequeue perfomance InOut ExchangePattern

There is API on CamelContext to create a new consumer template. Then you can 
create it once, and re-use it.
A bit like reusing a producer template as stated in this FAQ 
http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html

On Mon, Nov 21, 2011 at 5:38 PM, Carlos Manuel Figueiredo 
<carlos-m-figueir...@ext.ptinovacao.pt> wrote:
> 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
>



--
Claus Ibsen
-----------------
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to