I'm reading over Sun's JMS tutorial and it mentions several times that JMS (and therefore ActiveMQ) can keep out duplicate messages if consumers set their session to AUTO_ACKNOWLEDGE. But I don't see how that's always the case. Consider this timeline:

1. Consumer registers an asynchronous listener for a queue.
2. Producer injects a persistent message into said queue.
3. Consumer's onMessage() is called and the message is processed.
4. Broker crashes.
5. Consumer tries to ack the message is just successfully processed - woops. Consumer tears down its session. 6. Broker comes back online; consumer reconnects, re-registers its asynchronous listener.
7. Consumer gets a duplicate message.

What am I missing?

Reply via email to