message nacked error after publishing message

187 views
Skip to first unread message

Neville T

unread,
Aug 12, 2022, 12:53:36 PM8/12/22
to rabbitmq-users
Hello Folks,
Hope everyone is doing well.
Getting the following error on NodeJS Server when I try to publish to the queue. message nacked.
Using 
NodeJS version - 14.18.2
amqplib - 0.6.0
I use following method to publish to the queue

Sample code to publish to queue

async function init() 
const connection = await amqp.connect(config.rabbitmq.url);
const e = config.rabbitmq.exchange;
const channel = await connection.createChannel();
  await channel.assertExchange(e, 'fanout', { durable: false, autoDelete: true });  channel.publish(e, '', Buffer.from(process.argv[2] || 'something to do')) 
setTimeout(async () => { await connection.close() }, 500) 
}
NOTE - I also use the following method with a time delay based on requirement.
channel.sendToQueue

Full error context:
Error: message nacked
    at /home/node/node_modules/amqplib/lib/channel.js:34:16
    at Array.forEach (<anonymous>)
    at ConfirmChannel.C.handleConfirm (/home/node/node_modules/amqplib/lib/channel.js:358:15)
    at ConfirmChannel.emit (events.js:400:28)
    at ConfirmChannel.C.accept (/home/node/node_modules/amqplib/lib/channel.js:406:17)
    at Connection.mainAccept [as accept] (/home/node/node_modules/amqplib/lib/connection.js:64:33)
    at Socket.go (/home/node/node_modules/amqplib/lib/connection.js:478:48)
    at Socket.emit (events.js:400:28)
    at emitReadable_ (internal/streams/readable.js:555:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

Any help is appreciated. Thanks
Neville
Reply all
Reply to author
Forward
0 new messages