Closed eugenebuhor closed 1 year ago
Messages which are unacknowledged are released back to the queue according to these rules: https://www.rabbitmq.com/confirms.html#automatic-requeueing
In the second approach, you probably have to stop consuming before nacking the message if you want to prevent it from being immediately consumed again.
Thanks @luddd3. Although as you can see from the first approach the message is ack'ed manually only in the try
block. And this way I expect to receive the message back to the queue when I re-connect to the provider stream. But I don't see the message. Is there anything I'm missing or could you investigate if there's an issue with your layer?
Note that it takes some time for RabbitMq to detect a failed connection.
We have no reason yet to believe that there is something wrong with how node-amqp-reconnection-manager
handles the ack/nack.
Can you try your logic with just amqplib
and verify that the message is released back into the queue when you lose connection? Or maybe provide a code example that reproduces your issue.
Environment:
Precondition
Desctiption: We have a node process run and connected to rebbitmq stream queue. We need to remove auto acknowledgment of messages in the queue and do it manually. In the particular case, we suppose to acknowledge an upcoming message only if it is handled w/out errors. And if there is an error we do not acknowledge the message to keep it in the queue, and instead we escalating the error up to fix it manually and restart the process. So that way when we reconnect to the queue we expect the message still be there.
Here's the snippet of the
consume
function, where we disable auto-ack and ack messages manually. The issue with this one is when we reconnect to the queue, the message is not there.This is another way we were trying to achieve that behavior. We're trying to nack messages manually - put the "failed" message back in the queue. But the message is not "waiting" to come until reconnect, instead it constantly gets into handler because we nack it manually every time.
Question: