【问题标题】:How to find number of queues bound to a particular exchange in rabbitmq?如何在rabbitmq中查找绑定到特定交换的队列数?
【发布时间】:2016-07-04 17:01:00
【问题描述】:

我正在尝试在 Java 中实现 Rabbitmq 教程中指定的发布/订阅模型。那里提供的示例工作正常。现在我想对其进行修改,以限制访问 Exchange 的客户端数量。

当我查看它时,我可以找到一个命令“rabbitmqctl list_bindings”来列出有界队列,这是手动输入。有没有办法以编程方式做到这一点? 或者 我们是否有任何交换函数来返回绑定到交换的队列数?

我找不到任何东西,请帮助我,感谢任何帮助。

【问题讨论】:

    标签: java rabbitmq


    【解决方案1】:

    您可以使用management UI HTTP API,在这里您可以找到所有API

    您可以使用 API /api/exchanges/{vhost}/{exchange_name}/bindings/source

    例如:

    http://localhost:15672/api/exchanges/%2F/Topic_test/bindings/source
    

    你会得到一个 json 结果,类似于:

    
    [
    
        {
            "source": "Topic_test",
            "vhost": "/",
            "destination": "test_0",
            "destination_type": "queue",
            "routing_key": "",
            "arguments": { },
            "properties_key": "~"
        },
        {
            "source": "Topic_test",
            "vhost": "/",
            "destination": "test_1",
            "destination_type": "queue",
            "routing_key": "",
            "arguments": { },
            "properties_key": "~"
        },
        {
            "source": "Topic_test",
            "vhost": "/",
            "destination": "test_2",
            "destination_type": "queue",
            "routing_key": "",
            "arguments": { },
            "properties_key": "~"
        }
    ]
    

    【讨论】:

    • 感谢您的回复...它仍然是 UI ,我所期待的是,任何在 Java 程序本身中检索队列数的方法。像方法或其他东西一样以编程方式。
    • 哦,谢谢 Gabriele...我是这个 rabbitmq 的新手,所以我需要一些时间来完成它。我会在完成后回复您。
    • 同意。如何以编程方式从 Java 中获取此信息。
    • 只是一个http调用
    猜你喜欢
    • 2020-04-30
    • 1970-01-01
    • 2012-08-23
    • 1970-01-01
    • 2016-05-28
    • 1970-01-01
    • 2012-09-17
    • 2020-07-01
    • 1970-01-01
    相关资源
    最近更新 更多