const amqp = require('amqplib/callback_api'); amqp.connect('amqp://test2:test2@114.115.203.60:8071/test', function (error0, connection) { if (error0) { throw error0; } connection.createChannel(function (error1, channel) { if (error1) { throw error1; } const exchange = 'ex.test'; channel.assertExchange(exchange, 'topic', { durable: true }); channel.assertQueue('', { exclusive: true }, function (error2, q) { if (error2) { throw error2; } console.log(' [*] Waiting for logs. To exit press CTRL+C'); channel.bindQueue(q.queue, exchange, 'test3'); channel.consume(q.queue, function (msg) { console.log(" [x] %s:'%s'", msg.fields.routingKey, msg.content.toString()); }, { noAck: true }); }); }); });