简体   繁体   中英

Spring AMQP Get Existing Queue Names and Argument

We have a queue in production where message TTL was set via application. Now we want to change message TTL and attach policy via rabbit CTL than setting within application. 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?

Note: Overriding x-message-ttl with different value throws error.

RabbitMQ has a REST API and a java client for it .

You can use that to get information about existing elements such as queues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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