await/async:Channel#close()
callback:Channel#close([function(err) {…}])
// await/asynctry {const connection = await amqp.connect(url)const channel = await connection.createChannel();const queue = 'hello';const msg = 'Hello World!';await channel.assertQueue(queue, { durable: false });await channel.sendToQueue(queue, Buffer.from(msg));console.log(" [x] Sent %s", msg);await channel.close();setTimeout(async () => await connection.close(), 500)} catch (e) {console.log(e)}
// callback(async () => {amqp.connect(url, function (error, connection) {if (error) throw error;connection.createChannel((error1, channel) => {if (error1) throw error1;const queue = 'hello';const msg = 'Hello World!';channel.assertQueue(queue, {durable: false});channel.sendToQueue(queue, Buffer.from(msg));console.log(" [x] Sent %s", msg);channel.close();setTimeout(function () {connection.close();process.exit(0);}, 500);});})})()
