Skip to content

Monitoring a queue

ts
function MonitorQueue(queueName: string);

The MonitorQueue() function instructs the client object to start monitoring the specified queue for incoming messages.

Example

ts
{
  ConsoleFeedback = true;
  var cli = new AmqpClient091();
  cli.URL = 'amqp://localhost:5672';
  cli.User = 'guest';
  cli.Pass = 'guest';
  if (cli.Connect()) {
    cli.MonitorQueue('myqueue');
    while (true) {
      Sleep(1000);
      if (HaltSignalReceived()) {
        break;
      }
      var msgs = cli.GetMessages();
      if (msgs.length > 0) {
        Log(JSON.stringify(msgs));
      }
    }
    cli.Close();
  }
  cli = null;
}