node.jsrabbitmqmessage-queuerabbitmq-exchange

message is not acknowledged but in rabbitmqManagement page it said the queue is empty (but I sent the message)?


When I try to click getMessages button in RabbitMQManagement I get a response which says it is empty, as in the picture belove. enter image description here

However, I send 4 messages which are unacked because I make the acknowledgment manually. If the callback function in my consumer does not/cannot add the message in the database it does not acknowledges the message.

So the queue has persistent=true but here I see that the queue is empty.

How can I prevent this? How can I have the message in the queue until i aknowledge it?


Solution

  • The message is "still in the queue", just not available for consumption. Rabbitmq knows the messages have been given to consumer, and is waiting for the ack to delete them.

    If you reject, you have the option to requeue the message (where it will given for consumption again if a consumer is availavble), or not.

    I'd typically recommend configuring a dead letter exchange and reject the message without requeue as a more sturdy solution (you'd have configured a queue bound to the defined dead letter exchange).

    In such case the rejected message would be published to the dead letter exchange and finish in the dead letter queue (the queue bound to the dead letter exchange) where you can consume them for review or other secondary processing.