Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetch message from ActiveMQ queue without dequeueing

Tags:

java

jms

activemq

I am taking messages from ActiveMQ queue and running a Java application which can succeed or fail.

In case the application fails, i want the message to remain on the queue, that is to keep it without dequeueing it.

Is there a way to take a message with out automaticly erasing it from the queue?

Is there are atom operation like fetching from queue or erasing from queue?

Thanks.

like image 724
Michael A Avatar asked Jan 15 '23 22:01

Michael A


1 Answers

Disable auto-acknowledge of messages, and then call message.acknowledge() manually after the work is done. If an exception is thrown and thus the message.acknowlege() is not called, AMQ will attempt to deliver the message again. If all attempts fail, the message is finally placed in the dead letter queue. This behavior can be configured.

like image 78
mbelow Avatar answered Jan 27 '23 00:01

mbelow