I'm going through a problem upon dealing messages from a queue. My MDB reads the message M from Queue Q. Inside onMessage method there are some calls to other services. Whenever a transaction fails inside those services, the MDB instance is destroyed and message M is sent back to the Queue Q. I want to avoid this behavior, what I mean is that I want to avoid message Me to be resent to the queue. Is is possible?
MDB is in a Bean Managed Transaction.
You say you are using a bean managed transaction - so you are calling begin and commit from onMessage. In that case the message is delivered to the MDB outside that transaction (using auto-acknowledgement by default). This means that rolling back the transaction should not cause the message to be redelivered. Is your bean throwing an exception? That (and not the rollback) might be what is causing the message to be redelivered.