简体   繁体   English

Spring AMQP 获取现有队列名称和参数

[英]Spring AMQP Get Existing Queue Names and Argument

We have a queue in production where message TTL was set via application.我们在生产中有一个队列,其中消息 TTL 是通过应用程序设置的。 Now we want to change message TTL and attach policy via rabbit CTL than setting within application.现在我们想通过兔子 CTL 更改消息 TTL 和附加策略,而不是在应用程序中设置。 Snippet:片段:

    Map<String, Object> args = new HashMap<>();
    args.put("x-message-ttl", 86400000);
    for (String queueName : queueNames) {
            Queue queue = new Queue(queueName, true, false, false, args);
            admin.declareQueue(queue);
     ...
    }

To achieve this in running application we want way to validate if Queue already exists do nothing otherwise create new Queue without args.为了在运行的应用程序中实现这一点,我们需要验证队列是否已经存在的方法,否则什么都不做,否则创建没有参数的新队列。 It is not possible to leverage local cache as multiple publisher/subscriber nodes can restart under unplanned outage scenario.无法利用本地缓存,因为多个发布者/订阅者节点可以在计划外中断情况下重新启动。 With above would be able to change TTL during Rabbit upgrade/Migration Can you help if there is an API to fetch all existing queues and its argument properties?如果有一个 API 来获取所有现有队列及其参数属性,上面将能够更改 TTL?

Note: Overriding x-message-ttl with different value throws error.注意:用不同的值覆盖 x-message-ttl 会引发错误。

RabbitMQ has a REST API and a java client for it . RabbitMQ 有一个 REST API 和一个Z93F725A07423FE1C8846F448B33D21 客户端

You can use that to get information about existing elements such as queues.您可以使用它来获取有关现有元素(例如队列)的信息。

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

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