Integration / ActiveMQ Interview Questions Intermediate
How does message acknowledgment work in ActiveMQ?
When a consumer receives a message, the broker marks it as dispatched but keeps it in its store until an acknowledgment arrives, rather than deleting it right away.
The exact trigger for that acknowledge() call depends on the session's ack mode - automatic right after delivery, explicit via client code, or tied to a transaction commit. If the consumer disconnects before acknowledging, the broker treats the message as still pending and redelivers it once a consumer is available again.
DUPS_OK_ACKNOWLEDGE relaxes this slightly by letting the client acknowledge lazily and in batches for better throughput, accepting that a crash between processing and the lazy ack could cause a duplicate delivery. SESSION_TRANSACTED ties acknowledgment to a transaction boundary instead of an individual call, so a whole batch of receives is acknowledged, or rolled back, together as one unit whenever commit() or rollback() is invoked.
More Related questions...