You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Ben Chobot <bc...@vigilos.com> on 2008/02/20 22:10:35 UTC

AUTO_ACKNOWLEDGE, asynchronous consumers, and avoiding duplicate messages

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?