RMQ Consumer (Node.js)

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

const amqp = require("amqplib");

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

const queue = "_PackageID_";

async function receiveMessage() {
  try {
    const connection = await amqp.connect(connectionParams);
    const channel = await connection.createChannel();

    console.log("Waiting for messages in queue:", queue);
    channel.consume(
      queue,
      function (msg) {
        console.log("Received message:", msg.content.toString());
      },
      {
        noAck: true,
      }
    );
  } catch (error) {
    console.error(error);
  }
}

receiveMessage();

Last updated

Was this helpful?