javajmsmessage-driven-bean

How to acknowledge messages in Message Driven Beans


In the JMS documentation I read that Message Driven Beans doesn't support CLIENT_ACKNOWLEDGE mode, only DUPS_OK_ACKNOWLEDGE and AUTO_ACKNOWLEDGE.

As I understand it, in AUTO_ACKNOWLEDGE mode, the message is acknowledged (deleted from the destination) when the onMessage method is invoked. What I want is to tell my broker not to delete messages from the destination (queue or topic) when something bad happens

There must be some way to do this. Anyway, why is CLIENT_ACKNOWLEDGE not supported in Message Drven Beans.


Solution

  • What I want is to tell my broker not to delete messages from the destination (queue or topic) when something bad happens.

    If you're configured to use PERSISTENT messages, any exceptions in onMessage() will persist the message for redelivery based on broker and destination settings. If you're using NON_PERSISTENT messages, any exception in onMessage() typically discards the message.

    Anyway, why is CLIENT_ACKNOWLEDGE not supported in Message Driven Beans.

    Message-driven beans are managed by the J2EE container; as such, the container handles acknowledgements. Typically, only stand-alone JMS receivers should use CLIENT_ACKNOWLEDGE.

    What messaging middleware are you using?