'sendToQueue() of amqplib doesn't throw any error even if the queue does't exist
I created a queue named 'test_queue' with amqplib
then I deleted the 'test_queue' from the admin page of rabbitmq (http://localhost:15672/#/queues)
but when I excute the following code, it shows 'sent message successfully!'
there is no error even if the queue named 'test_queue' does't exist
How to get an error when queue doesn't exist?
Thanks for any help!
const amqp = require('amqplib');
const sendMsg=async ()=>{
const connection = await amqp.connect('amqp://localhost');
const ch = await connection.createConfirmChannel()
const msg= 'hello world'
const QUEUE_NAME = 'test_queue'
ch.sendToQueue(QUEUE_NAME, Buffer.from(msg),{},function(err, ok) {
if (err !== null) {
console.log(err);
} else {
console.log('sent message successfully!');
}
})
// await ch.close();
// await connection.close();
}
sendMsg();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|