RMQ Consumer (JavaScript)

Make sure to adjust the following fields as described on documentation : * <UserName> = username * <Password> = password * <HostName> = OS - InPlay: inplay-rmq.lsports.eu / PreMatch: prematch-rmq.lsports.eu STM - InPlay: stm-inplay.lsports.eu / PreMatch: stm-prematch.lsports.eu * <VirtualHost> = OS = VirtualHost = "Customers" STM = VirtualHost = "StmPreMatch" / VirtualHost = "StmInPlay" * <PackageID> = should be a number between “_“ for example _100_

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