Signal a rollback from a JMS MessageListener

后端 未结 3 1594
粉色の甜心
粉色の甜心 2021-02-05 19:28

I\'ve been working with JMS and ActiveMQ. Everything is working wonders. I am not using spring, nor can I.

The interface javax.jms.MessageListener has only

3条回答
  •  灰色年华
    2021-02-05 19:49

    You need to set the acknowledgment mode to Session.CLIENT_ACKNOWLEDGE, the client acknowledges a consumed message by calling the message's acknowledge method.

    QueueSession session = connection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);

    Then, after processing the message to need to call the Message.acknowledge() method in order to remove that message.

    Message message = ...;
    // Processing message
    
    message.acknowledge();
    

提交回复
热议问题