You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tim Dudgeon <td...@gmail.com> on 2015/06/08 11:24:33 UTC

programatic access to jms queue

I'm wanting to programatically access a JMS queue on a dynamic basis, 
but use the Camel infrastructure to do this.
I've tried something like this:

JmsEndpoint jms = 
getCamelContext().getEndpoint("activemq:queue:myqueue", JmsEndpoint.class);
JmsConsumer consumer = jms.createConsumer((Exchange exchange) -> {
Object body = exchange.getIn().getBody();
System.out.println("BODY: " + body);
});
consumer.start();

But this only processes the first message in the queue.
How should I be doing this?


Tim

Re: programatic access to jms queue

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

This is correct. The consumer will keep running until you call stop.
Mind the start method is not blocking.

On Mon, Jun 8, 2015 at 11:24 AM, Tim Dudgeon <td...@gmail.com> wrote:
> I'm wanting to programatically access a JMS queue on a dynamic basis, but
> use the Camel infrastructure to do this.
> I've tried something like this:
>
> JmsEndpoint jms = getCamelContext().getEndpoint("activemq:queue:myqueue",
> JmsEndpoint.class);
> JmsConsumer consumer = jms.createConsumer((Exchange exchange) -> {
> Object body = exchange.getIn().getBody();
> System.out.println("BODY: " + body);
> });
> consumer.start();
>
> But this only processes the first message in the queue.
> How should I be doing this?
>
>
> Tim



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/