Integration / ActiveMQ Interview Questions Advanced
What happens internally when a broker restarts with pending persistent messages?
On startup, ActiveMQ's persistence adapter, KahaDB by default, replays its data log files to reconstruct the in-memory index of which messages exist on which destinations and which transactions were in-flight but not yet committed at shutdown.
Any message that was durably stored and never acknowledged before the broker went down is restored to its destination exactly as it was, so consumers reconnecting after the restart see the same pending backlog they would have seen had the broker never gone down - messages are not lost or silently dropped. Transactions left uncommitted at the moment of shutdown are typically rolled back during this recovery, since a transaction is only durable once commit() has been fully applied.
If the shutdown was unclean, a crash rather than a graceful stop, KahaDB may need extra time to verify or repair its index against the log files before the broker can accept connections again, which is one reason very large, uncompacted data log directories can noticeably slow down startup after a crash. Non-persistent messages that existed only in memory at the time of the crash are gone permanently, since by design they were never written to disk.
It's also worth knowing that a broker's startup time after a crash is roughly proportional to how much unreclaimed log data KahaDB has to scan and validate, which is one practical reason operators keep an eye on KahaDB's total data directory size in production - a broker whose disk usage has silently grown unchecked, perhaps because a stuck durable subscriber is pinning old log files, can take noticeably longer to come back online after an unexpected outage than one whose store is regularly compacted.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
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.
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! Receive free stock by signing up using the link: Webull signup.
More Related questions...
