RabbitMQ Management API调用

RabbitMQ在运行时,偶尔会有一些死信,即消息未正常消费,造成消息积压在消息队列中, 一直卡住,重复循环消费原来的消息队列

那么就需要有一种机制,来查看RabbitMQ是否有消息未正常消费,从而让RabbitMQ消费端重新启动服务,让消息能顺利消费(例如让Windows Service重启等)

首先,查看RabbitMQ Manage的界面,可以看到,这里未应答的消息总数是0,在某些特定的情况下,有可能会出现未应答的消息的,所以需要进行检测

RabbitMQ Management API调用

 

 

RabbitMQ Management API文档地址:https://pulse.mozilla.org/api/

RabbitMQ Management API调用

 

我们这里使用的API是/api/queues/vhost/name

请记住,其中vhost参数使用提默认的 ,需要Encoding为%2F

RabbitMQ Management API调用

 

 

Postman中如下

权限部分使用Basic Auth,并输入RabbitMQ Management的用户名和密码

RabbitMQ Management API调用

 

返回的JSON如下

RabbitMQ Management API调用
{
    "consumer_details": [],
    "arguments": {},
    "auto_delete": false,
    "backing_queue_status": {
        "avg_ack_egress_rate": 0.0,
        "avg_ack_ingress_rate": 0.0,
        "avg_egress_rate": 0.0,
        "avg_ingress_rate": 0.0,
        "delta": [
            "delta",
            16384,
            57,
            0,
            98304
        ],
        "len": 61,
        "mode": "default",
        "next_seq_id": 98304,
        "q1": 0,
        "q2": 0,
        "q3": 3,
        "q4": 1,
        "target_ram_count": "infinity"
    },
    "consumer_utilisation": null,
    "consumers": 0,
    "deliveries": [],
    "durable": true,
    "effective_policy_definition": {},
    "exclusive": false,
    "exclusive_consumer_tag": null,
    "garbage_collection": {
        "fullsweep_after": 65535,
        "max_heap_size": 0,
        "min_bin_vheap_size": 46422,
        "min_heap_size": 233,
        "minor_gcs": 19
    },
    "head_message_timestamp": null,
    "idle_since": "2019-11-04 8:57:13",
    "incoming": [],
    "memory": 30772,
    "message_bytes": 20576,
    "message_bytes_paged_out": 0,
    "message_bytes_persistent": 20576,
    "message_bytes_ram": 1247,
    "message_bytes_ready": 20576,
    "message_bytes_unacknowledged": 0,
    "messages": 61,
    "messages_details": {
        "rate": 0.0
    },
    "messages_paged_out": 0,
    "messages_persistent": 61,
    "messages_ram": 4,
    "messages_ready": 61,
    "messages_ready_details": {
        "rate": 0.0
    },
    "messages_ready_ram": 4,
    "messages_unacknowledged": 0,
    "messages_unacknowledged_details": {
        "rate": 0.0
    },
    "messages_unacknowledged_ram": 0,
    "name": "SyncData.5c8f2d5c806f0b43fc4a7a5c",
    "node": "rabbit@rabbit",
    "operator_policy": null,
    "policy": null,
    "recoverable_slaves": null,
    "reductions": 107151,
    "reductions_details": {
        "rate": 0.0
    },
    "single_active_consumer_tag": null,
    "state": "running",
    "type": "classic",
    "vhost": "/"
}
View Code

 

其中Ready和Unacked的消息如下

RabbitMQ Management API调用

 

RabbitMQ Management API调用

上一篇:appium之java API(2)


下一篇:windows server 2008R2 配置tomcat服务开机自启动