Is there a ping equivalent for RabbitMQ? How can I diagnose if an exchange or queue is being broadcast?

I use postwait/node-amqp( link ) to connect to various exchanges and queues of RabbitMQ in our organization.

As my project moved from dev to production, I ran into several issues related to incorrect queuing or incorrect passwords, etc. In the latter case, obviously, I will get an ECONNREFUSED error. In the first case, however, I do not get any errors, just a timeout when connecting.

Given a URI, such as amqp://USER:PASS@messaging.abc.xyz.comhow can I determine if the "FooWorkItems.Work" queue accepts connections for listening? What is the minimum code for this, the equivalent of checking if the API is listening or the server is connected and listening on the ping port?

The code:

if (this.amqpLib == null) {
    this.amqpLib = require('amqp');
  }
this.connection = this.amqpLib.createConnection({
    url: this.endpoint
  });

  this.connection.on('ready', (function(_this) {
    return function() {
      var evt, _fn, _fn1, _i, _j, _len, _len1, _ref, _ref1;
      _this.logger.info("" + _this.stepInfo + " connected to " + _this.endpoint + "; connecting to " + queueName + "  now.");
      if (_this.fullLogging) {
        _ref = ['connect', 'heartbeat', 'data'];
        _fn = function(evt) {
          return _this.connection.on(evt, function() {
            _this.logger.trace("" + _this.stepInfo + " AMQP event: " + evt);
            if (arguments != null) {
              return _this.logger.trace({
                args: arguments
              });
            }
          });
        };
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          evt = _ref[_i];
          _fn(evt);
        }
        _ref1 = ['error', 'close', 'blocked', 'unblocked'];
        _fn1 = function(evt) {
          return _this.connection.on(evt, function() {
            if (evt !== 'close') {
              return _this.logger.error("" + _this.stepInfo + " AMQP event: " + evt);
            } else {
              return _this.logger.warn("" + _this.stepInfo + " AMQP event: " + evt);
            }
          });
        };
        for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
          evt = _ref1[_j];
          _fn1(evt);
        }
      }
      return _this.connection.queue(_this.queueName, {
        passive: true
      }, function(q) {
        logger.debug("" + stepInfo + " connected to queue " + queueName + ". Init complete.");
        return q.subscribe(function(message, headers, deliveryInfo, messageObject) {
          logger.trace("" + stepInfo + " recvd message");
          return logger.trace({
            headers: headers
          });
        });
      });
    };
+9
source share
1 answer

In amqp, queues and exchanges are concepts that are not connected, they do not listen and do not broadcast, and you cannot connect to them, only to the broker.

The RabbitMQ server, of course, accepts network connections, and the protocol defines a logical connection over the transport, this connection includes a pulse configured by using the option heartbeatin this library.

, , -, , , "ping". , , , .

reconnect postwait/node-ampq, .

+1

All Articles