camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tarun Kumar <agrawal.taru...@gmail.com>
Subject Polling consumer in camel
Date Wed, 18 Dec 2013 18:59:37 GMT
Hi,

I am creating a polling consumer using:

from("timer://foo?period=5000").bean(cool, "someBusinessLogic");

public static class MyCoolBean {

    private int count;
    private ConsumerTemplate consumer;
    private ProducerTemplate producer;

    public void setConsumer(ConsumerTemplate consumer) {
        this.consumer = consumer;
    }

    public void setProducer(ProducerTemplate producer) {
        this.producer = producer;
    }

    public void someBusinessLogic() {
        // loop to empty queue
        while (true) {
            // receive the message from the queue, wait at most 3 sec
            String msg = consumer.receiveBody("activemq:queue.inbox", 3000,
String.class);
            if (msg == null) {
                // no more messages in queue
                break;
            }

            // do something with body
            msg = "Hello " + msg;

            // send it to the next queue
            producer.sendBodyAndHeader("activemq:queue.foo", msg, "number",
count++);
        }
    }
}

Here, i would like to receive jms message as Message or TextMessage instead
of string. I have tried:

Exchange exchange = consumer

  .receive("catalogJms:queue:queueName");

exchange also doesn't give me message as javax.jms.Message or TextMessage.


Is there any way i can do this?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message