Integration / ActiveMQ Interview Questions Advanced
Explain the execution flow of a transacted session in ActiveMQ?
In a JMS transacted session (createSession(true, ...) or SESSION_TRANSACTED), all sends and receives performed between commit() calls are grouped into one atomic unit of work. Messages sent within the transaction aren't visible to consumers until commit() succeeds; calling rollback() instead means none of the sent messages are ever delivered. Messages received within the transaction aren't permanently removed until commit either; rollback returns them to the destination, often redelivered with an incremented redelivery counter, as if they had never been taken.
Internally, the broker tracks a transaction context tied to the session, buffering the enqueue and dequeue operations, and only applies them durably to the destination and persistence store atomically once commit() is received - so either every operation in the transaction takes effect or none do. This is what makes the classic "receive from Queue A, process, send to Queue B" pattern safe: a failure partway through processing can roll back both the removal from A and the send to B together, avoiding a state where the message vanishes from A but never makes it to B.
One consequence worth knowing: a transacted session's commit() and rollback() apply to every send and receive performed on that session since the previous boundary, not just the last operation, so mixing unrelated units of work on a single transacted session can accidentally roll back or commit more than intended. This is why applications typically dedicate a session, and its transaction boundary, to one coherent unit of work, such as a single "receive, transform, forward" cycle, rather than sharing one long-lived transacted session across unrelated processing paths.
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...
