Processing incoming messages

function GetMessages(): QueueMsg

QueueMsg = {
  receivedAt: Date // JavaScript date object
  queue:      string
  message:    string
}

It is recommended, inside the loop in which GetMessages() is called iteratively, to also monitor whether a “halt” request has been issued and the script must terminate.

Example:

{
  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;
}