Integration / ActiveMQ Interview Questions Advanced
Explain the execution flow of a JMS transaction rollback in ActiveMQ?
When rollback() is called on a transacted session, the broker undoes every operation buffered under that transaction's context since the last commit. Messages sent within the transaction are simply discarded and never delivered to any consumer, as if send() had never been called at all. Messages received within the transaction are returned to their original destination so they become available for redelivery, with ActiveMQ incrementing the message's redelivery counter and, if a redelivery policy is configured, applying a delay before the same or another consumer picks it up again.
Internally, the broker's transaction manager for that session tracks a list of pending enqueue and dequeue operations tagged to the transaction ID. commit() flushes them atomically to the persistence store and destination structures, while rollback() simply discards the enqueue operations and reverses the dequeue operations, restoring pre-transaction state without touching the persistence store at all. This design means a transaction failure never leaves the broker in a half-applied state - either the whole batch of sends and receives lands, or none of it does - which is exactly what lets applications safely retry a failed unit of work without worrying about partial side effects on the broker side.
One easy-to-miss detail is that rollback does not reset the redelivery delay clock for received messages the way a fresh send would - a message that has already been rolled back several times keeps accumulating its redelivery count, so if a redelivery policy with a maximum retry limit is configured, repeatedly rolling back the same problematic message will still eventually route it to the Dead Letter Queue rather than looping forever.
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...
