Integration / ActiveMQ Interview Questions Advanced
Explain the internal working of ActiveMQ's KahaDB persistence store?
KahaDB is ActiveMQ's default file-based persistence adapter. It combines a write-ahead log with an index so persistent messages survive broker restarts without requiring random-access disk writes for every operation.
When a persistent message arrives, KahaDB appends it to the current active data log file sequentially, which is cheap because it requires no disk seek, then updates its page-file index entry pointing to that offset. Message removal after acknowledgment doesn't rewrite the log entry in place; instead it marks the entry as deleted in the index. A background process periodically checks whether every message in an older data log file has been marked deleted, and once a whole file is fully consumed, KahaDB deletes that entire file rather than compacting individual records, keeping the reclaim cost low.
On broker restart, KahaDB replays the data logs to rebuild its index, which is why very large uncompacted logs can slow down startup after an unclean shutdown. This log-structured design trades some read-path indirection for very fast sequential writes, which is why KahaDB generally outperforms JDBC persistence for a single, locally-attached broker, though it doesn't natively support shared storage across multiple broker instances the way a database can.
Because reclaiming a file requires every message in it to be fully consumed first, a single long-lived unacknowledged message can indefinitely pin down an entire data log file, which is a common, if underappreciated, cause of disk usage that keeps climbing even though most traffic is flowing normally.
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...
