Get the number of queues and the like RabbitMQ message information via http API

reference

RabbitMQ provides HTTP API manual and found that the situation obtaining queue API. (Native API manual address: HTTP: // localhost: 15672 / API )

All API calls are required to do to verify permissions, permission must be added to verify the information in the request header

1. Get all the information queue

http://host:15672/api/queues


2. Obtain a single queue information

HTTP: // Host: 15672 / API / Queues / vhost / name
Host deploy address RabbitMQ, vhost virtual host name where the queue, name for the queue name.

Note: If the queue is located default virtual host that the host name is "/", need to "/" url after transcoding ( "% 2f") request Request

 static  void the Main ( String [] args) 
        { 
            #region myregion
             // to obtain information related to the queue by Api RabbitMq 
            var URL = " http://192.168.0.37:15672/api/queues/%2f/Citms.Queue. LXEPP.VideoMq " ;
             // Create HttpClient (note incoming HttpClientHandler) 
            var Handler = new new HttpClientHandler () = {AutomaticDecompression DecompressionMethods.GZip};
             var username = " ADMIN " ;
             var password = " citms " ;           
            using (var http = new HttpClient(handler))
            {
                string auth = username + ":" + password;
                byte[] b = System.Text.Encoding.Default.GetBytes(auth);
                var a = Convert.ToBase64String(b);
                http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", a);
                var response = http.GetAsync(url).Result;//传参使用
                //HTTP ensure success status value 
                response.EnsureSuccessStatusCode ();
                 // the await asynchronous read the last JSON (note that this time has been automatically decompressed gzip, because the above DecompressionMethods.GZip = AutomaticDecompression) 
                var Result = response.Content.ReadAsStringAsync ( ) .Result;
                 var JSON = JsonConvert.DeserializeObject < Dynamic > (Result); 
            } 
}

 

Guess you like

Origin www.cnblogs.com/macT/p/11983068.html