简体   繁体   English

RabbitMQ队列大小没有Spring? (Java API)

[英]RabbitMQ queue size without Spring? (java api)

I'm using the Java client with RabbitMQ. 我将Java客户端与RabbitMQ一起使用。 I've seen references to finding queue size with a Spring plugin, but I'm not using Spring. 我已经看到了使用Spring插件查找队列大小的参考,但是我没有使用Spring。 Is there a non-Spring way to get the size of a queue given its name? 有没有一种非Spring方法来获取给定队列名称的队列大小? Right now I'm just exec'ing shell commands 'rabbitmqctl list_queues' and parsing the results--not great. 现在,我只是执行shell命令“ rabbitmqctl list_queues”并解析结果-不太好。

you can enable the http management plugin , 您可以启用http管理插件

rabbitmq-plugins enable rabbitmq_management

then use the http API . 然后使用http API

If you execute an http call like: 如果您执行类似http的调用:

http://your_server/api/queues/your_virtual_host/yourqueue

you have all information about the queue, the output is a json like: 您具有有关队列的所有信息,输出为json,例如:

  ... "backing_queue_status": {
    "q1": 0,
    "q2": 0,
    "delta": [
      "delta",
      0,
      0,
      0
    ],
    "q3": 0,
    "q4": 0,
    "len": 0,
    "target_ram_count": 0,
    "next_seq_id": 0,
    "avg_ingress_rate": 0,
    "avg_egress_rate": 0,
    "avg_ack_ingress_rate": 0,
    "avg_ack_egress_rate": 0,
    "mirror_seen": 0,
    "mirror_senders": 0
  },
  "incoming": [],
  "deliveries": [],
  "consumer_details": [],
  "name": "myqueue",
  "vhost": "vhost",
  "durable": true,
  "auto_delete": false,
  "arguments": {},
  "node": "rabbit@lemur01"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM