RMQ Consumer (JavaScript)

const amqp = require('amqplib/callback_api');

const connectionParams = {
  hostname: 'HostName',
  port: 5672,
  username: '<Username>',
  password: '<Password>',
  vhost: 'VHost'
};

const queue = '_<PackageID>_';

amqp.connect(connectionParams, function(error0, connection) {
  if (error0) {
    throw error0;
  }
  connection.createChannel(function(error1, channel) {
    if (error1) {
      throw error1;
    }
    console.log("Waiting for messages in queue:", queue);
    channel.consume(queue, function(msg) {
      console.log("Received message:", msg.content.toString());
    }, {
      noAck: true
    });
  });
});

Last updated