How does RabbitMQ view all consumers of a queue [Troubleshooting]

Version:

spring-rabbit-1.6.10.RELEASE

spring-boot-autoconfigure-1.3.7.RELEASE

When using RabbitMQ, I encountered a problem. After sending a message, I found that there are multiple consumers, and this consumer is not the Listener I wrote.

In order to find the IP and port of this consumer, I need to see which consumers are currently on this queue.

Directly access the RabbitMQ management interface http://localhost:15672, and find a problem that some consumers will not be displayed here.

And in many cases, the consumer list is empty, as follows:

How can I view the list of currently registered consumers? Researched the API documentation and found an efficient way.

By accessing the http://localhost:15672/api/consumers interface, you can get all consumers registered on the current RabbitMQ.

{
  "arguments": {},
  "prefetch_count": 1,
  "ack_required": true,
  "exclusive": false,
  "consumer_tag": "amq.ctag-ggdoNEKhLKNpb3XoWNmyzhQ",
  "queue": {
    "name": "XXXX_XXXX_QUEUE",
    "vhost": "dev"
  },
  "channel_details": {
    "name": "127.0.0.1:26290 -> 1127.0.0.2:5672 (13)",
    "number": 13,
    "user": "guest",
    "connection_name": "127.0.0.1:26290 -> 1127.0.0.2:5672",
    "peer_port": 26290,
    "peer_host": "127.0.0.3"
  }
}

Take the following data as an example, peer_host and peer_port are the IP and port of the consumer

Using the /api/consumers interface, you can query the following raw data, and you can see the current list of all consumers.

Consumers that are not displayed in the http://localhost:15672 management interface, this interface will also return. Therefore, it is more reliable to use this interface for problem location.

In this way, the uninvited consumer was successfully identified, and the problem was solved.

In addition, the http://localhost:15672/api document is the data source of the RabbitMQ management interface. It is the most original data and is more comprehensive and reliable.

Although the visual interface is convenient, there are also some problems. Therefore, when using it, we have to choose selectively.

It can also be accessed from the command line:

:: Windows
C:> curl -i -u guest:guest http://localhost:15672/api/vhosts

# Unix
$ curl -i -u guest:guest http://localhost:15672/api/vhosts

HTTP/1.1 200 OK
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
Date: Mon, 16 Sep 2013 12:00:02 GMT
Content-Type: application/json
Content-Length: 30

[{"name":"/","tracing":false}]

For more information, please visit the RabbitMQ Management HTTP API: http://localhost:15672/api

Guess you like

Origin blog.csdn.net/m0_54853503/article/details/124012638