Forum Stats

  • 3,854,538 Users
  • 2,264,379 Discussions
  • 7,905,721 Comments

Discussions

How can i avoid a message to be resent to the queue after exception?

_blackjack
_blackjack Member Posts: 69
edited Aug 1, 2012 5:30AM in Java Message Service (JMS)
Hi All,

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.

Thanks

Answers

  • 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.

    Nigel
  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy
    The answer to your question is message broker specific. There was a message redelivery setting in JBoss 4.2.3, but that does not guarantee it is going to exist in all JMS implementations out there.
This discussion has been closed.