'Why do I get 'unknown delivery tag' error when I requeue a message in rabbitmq the second time?
In my application, after I get a message from rabbitmq, I push the message to a client, and wait for its ACK message, if the client doesn't reply with a ACK after some time, I requeue the message in rabbitmq with basic.reject with requeue being true.
This works fine for the first requeue operation, but after I requeue the same message for the second time, the channel is closed abruptly. From the server log, I get this error:
{amqp_error,precondition_failed,"unknown delivery tag 2",'basic.reject'}
I gather this is because the message has been removed from the queue. Why is this happening?
Solution 1:[1]
I had similar error
Error: Channel closed by server: 406 (PRECONDITION-FAILED) with message "PRECONDITION_FAILED - unknown delivery tag 1"
at Channel.C.accept (C:\Owlet\shopify_email_server\node_modules\amqplib\lib\channel.js:422:17)
at Connection.mainAccept [as accept] (C:\Owlet\shopify_email_server\node_modules\amqplib\lib\connection.js:64:33)
at Socket.go (C:\Owlet\shopify_email_server\node_modules\amqplib\lib\connection.js:478:48)
at Socket.emit (node:events:390:28)
at Socket.emit (node:domain:475:12)
at emitReadable_ (node:internal/streams/readable:578:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 406,
classId: 60,
methodId: 80
My solution was to assert channel with enabled option durable
channel.assertQueue(queueName, { durable: true });
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Adam |
