14

I know that Camel's JMS component, for receiving messages, uses Springs DefaultMessageListenerContainer. It can be configured to use CLIENT_ACKNOWLEDGE mode for acknowledging messages. My question is, when exactly the message.acknowledge() method gets called? Is it called internally by the spring's listener container?

Or can I somehow acknowledge message at my will?

I'd like to avoid scenario that messages get lost because my app crashed during processing of these messages and making it transactional seems a bit too heavy for me

Michal Pasinski
  • 568
  • 7
  • 20

1 Answers1

22

OK. After some some debugging and scanning throug source code I've found out that Camel uses spring MessageListenerContainers. The AbstractMessageListenerContainer, in case of CLIENT_AKNOWLEDGE mode, invokes comitIfNecessary method acknowledging message. This happens only AFTER registered MessageListener processes message succesfully (no exceptions)

Camel uses EndpointMessageListener which, eventually, invokes process method of next processor (or Producer) down the route. As this is classic chain of responsibilities, if any processor down the route throws exception or sets exception on the Exchange, it will be re-thrown by EndpointMessageListener preventing the AbstractMessageListener to acknowledge message.

Michal Pasinski
  • 568
  • 7
  • 20
  • 2
    Thanks bro for saving my time. – andrey Aug 25 '15 at 13:46
  • Can one disable this behavior so I can manually ack messages outside of camel context? What will happen if I do not ack a message at all? Is there a timeout until it becomes active again for other consumers? – Rob Sep 21 '18 at 14:11