-->

How to handle Container Managed,Auto Acknowledge,

2019-09-05 10:35发布

问题:

I got a MDB - EJB 2.1, WebSphere 7 version

Container Managed and Auto Acknowledged

Transactions marked as Not Supported

Now how do I handle exceptions in a way that the message will be preserved during exception and redelivered later?

I tried to throw runtime exception from the catch block inside my MDB onMessage method. But that seems to stop the MDB Listener which is unexpected.

I cannot call context.setRollBackOnly() as there is no transaction.

回答1:

RuntimeException should be fine. Check this out Message-driven beans - transaction support. If your Listener stops, then you have probably Maximum retries set to 0. Set it to something higher.