Shishir
Shishir

Reputation: 881

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.

Upvotes: 0

Views: 1405

Answers (1)

Gary Russell
Gary Russell

Reputation: 174554

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

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

Upvotes: 1

Related Questions