Search code examples
apache-cameljmsapache-karafapache-servicemix

Camel route from JMS queue to custom class in Servicemix 6


I would like to make a camel route from JMS to a POJO which can receive a TextMessage. Right now I route to a bean like this:

from("jms:person_queue").to("bean:QueueConsumerBean?method=consume")

I then receive a String in my bean method. I would rather have a custom class with a onMessage method and a TextMessage. The reason is that I want to use client acknowledgement for the message, like a transaction.

Or is there another way to use client ack?


Solution

  • Camel's JMS consumer automatically handles the ack type for you. If the route succeeds, it will ack the message. If it doesn't (ie.. exchange hits an exception handler) it will roll it back.

    BIG WARNING: CLIENT_ACKNOWLEDGE's behavior is not intuitive.. per the JMS spec.. it ack's current message AND all previous in a session.. this cannot be counted on to be a per-message ack. If you need per-message ack.. use TRANSACTED.