Retrieve a message from an ActiveMQ queue without deleting

I take messages from the ActiveMQ queue and run a Java application that may succeed or fail.

If the application does not work, I want the message to remain in the queue, that is, save it without deleting it.

Is there a way to get a message to automatically remove it from the queue?

Is there an atom operation, for example, fetching from a queue or removing from a queue?

Thanks.

+4
source share
2 answers

Disable automatic confirmation of messages, and then call the message.acknowledge () command manually after shutting down. If an exception is thrown and therefore message.acknowlege () is not called, AMQ will try to send the message again. If all attempts fail, the message is finally queued with a dead letter. This can be customized.

+6
source

Another way is to use QueueBrowser . This allows you to "view messages in the queue without deleting them." However, this is more useful for verification purposes, from the semantics you described, mbelow's answer seems to be the right choice.

+2
source

All Articles