Lior
Lior

Reputation: 508

Is there a way to get a list of all declared queues in rabbitmq?

I'm using .net Rabbit libraries and i didn't found a way to this with those libraries, only with rabbit Rest API.

Upvotes: 1

Views: 4036

Answers (2)

Merter GÜLBAHAR
Merter GÜLBAHAR

Reputation: 431

Currently, We can use EasyNetQ.Management.Client packages or we can use RabbitMQ Management HTTP API

Sample C# Code (using RabbitMQ Management HTTP API)

    public void WriteQueueList()
    {
        string username = "rabbitmq_user";
        string password = "rabbitmq_pass";
        // RabbitMQ Management HTTP API Url
        string url = "http://localhost:8080/api/queues";
        HttpClient client = new HttpClient();
        string auth = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"));
        client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", auth);
        try
        {
            HttpResponseMessage response = client.GetAsync(url).Result;
            string responseBody = response.Content.ReadAsStringAsync().Result;
            Console.WriteLine(responseBody);
        }
        catch (HttpRequestException e)
        {
            Console.WriteLine($"Hata: {e.Message}");
        }
        finally
        {
            client.Dispose();
        }
    }
      

Upvotes: 2

Hasan
Hasan

Reputation: 1308

Like answered in this question, there is no direct implementation for getting list of queues in either python or c# at the moment.

Upvotes: 2

Related Questions