Prev Next

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.

sequenceDiagram Producer->>Broker: send(message) Broker->>Consumer: dispatch(message) Consumer->>Broker: acknowledge() Broker->>Broker: remove from store

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.

What does the broker do with a message before acknowledgment arrives?
What happens if the consumer disconnects before acknowledging?

Invest now in Acorns!!! 🚀 Join Acorns and get your $5 bonus!
Acorns Logo

Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!

Earn passively and while sleeping

Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.

Robinhood Logo

Invest now!!! Get Free equity stock (US, UK only)!

Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.

The Robinhood app makes it easy to trade stocks, crypto and more.


Webull Logo

Webull! Receive free stock by signing up using the link: Webull signup.

More Related questions...

Show more question and Answers...

ActiveMQ Interview Questions Advanced

Comments & Discussions