This content has been marked as final. Show 1 reply
user13394165 wrote:Use Container Managed Transactions, set the transaction attribute to required and call setRollbackOnly() on the MessageDrivenContext object.
It seems like MDB doesn't support CLIENT_ACKNOWLEDGE mode. It supports only DUPS_OK_ACKNOWLEDGE and AUTO_ACKNOWLEDGE modes.
Basically, I need to be able to leave a message in queue if something bad happenes or my business logic fails inside method onMessage() of my MDB. In short, I want container to redeliver that message to my mdb. So how can I achieve this?
Container Managed Transactions are handled by the container and the container would start a transaction when the message is picked up for delivery and commits only when the onMessage() successfully returns. An exception (or a rollback) would rollback everything including message delivery.
Be careful to set up strategies to expire messages. Also any DB (from an SLSB perhaps) calls from the MDB has to use XA drivers.