Nick
Nick

Reputation: 1269

Spring RabbitMQ get all declared queues

I'm trying to get a list of all declared queues for a particular Virtual Host, using spring Rabbit libraries. But I can't see how you do it. There does exist a RabbitAdmin class which allows you to declare a queue, but you can't retrieve a list of existing queues.

Any ideas?

Thanks.

Upvotes: 5

Views: 11377

Answers (3)

Steve Wall
Steve Wall

Reputation: 1932

Spring has an implementation now as well

http://docs.spring.io/spring-amqp/reference/htmlsingle/#management-template

When the management plugin is enabled, the RabbitMQ server exposes a REST API to monitor and configure the broker. A Java Binding for the API is now provided. In general, you can use that API directly, but a convenience wrapper is provided to use the familiar Spring AMQP Queue, Exchange, and Binding domain objects with the API. Much more information is available for these objects when using the com.rabbitmq.http.client.Client API directly (QueueInfo, ExchangeInfo, and BindingInfo respectively). The class RabbitManagementTemplate provides operations for the management apis. The two relating to this question are

List<Queue> getQueues();

List<Queue> getQueues(String vhost);

Upvotes: 3

Anton
Anton

Reputation: 1638

For those reading that in 2016 - Take a look on Hop (https://github.com/rabbitmq/hop), it aims to wrap RabbitMQ management API for Java.

Upvotes: 3

kzhen
kzhen

Reputation: 3118

You won't be able to do this from the Spring/Java client.

Instead there is a REST API which is part of the Management plugin http://www.rabbitmq.com/management.html

Take a look at http://hg.rabbitmq.com/rabbitmq-management/raw-file/rabbitmq_v3_0_2/priv/www/api/index.html for the full reference.

You will be interested in the section /api/queues to get all queues or /api/queues/vhost to get queues on a given vhost

Upvotes: 4

Related Questions