# RMQ Consumer (Node.js)

Make sure to adjust the following fields as described on documentation :\
\* \<HostName> = for InPlay: [**stm-inplay.lsports.eu**](http://stm-inplay.lsports.eu) **|** for PreMatch: [**stm-prematch.lsports.eu**](http://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();
```

{% file src="/files/PaqIjMVjmjulfoDDbC9c" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lsports.eu/u/trade/integration/code-samples/rmq-consumer-node.js.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
