1.获取队列的详细信息
public List queueDatail() throws IOException {
ArrayList rabbitMQList = new ArrayList<>();
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet request = new HttpGet("http://"+rabbitMqHost+":15672/api/queues");
request.addHeader("Authorization", "Basic " + Base64.getEncoder().encodeToString((rabbitMqUsername+":"+rabbitMqPassword).getBytes()));
HttpResponse response = httpClient.execute(request);
HttpEntity entity = response.getEntity();
String jsonString = EntityUtils.toString(entity);
JSONArray queues = new JSONArray(jsonString);
for (int i = 0; i < queues.length(); i++) {
RabbitMQ rabbitMQ = new RabbitMQ();
rabbitMQ.setName(queues.getJSONObject(i).getString("name"));
rabbitMQ.setType(queues.getJSONObject(i).getString("type"));
rabbitMQ.setState(queues.getJSONObject(i).has("state")?queues.getJSONObject(i).getString("state"):"running");
rabbitMQ.setReady(queues.getJSONObject(i).has("messages_ready")?String.valueOf(queues.getJSONObject(i).getInt("messages_ready")):"0");
rabbitMQ.setUnAcked(queues.getJSONObject(i).has("messages_unacknowledged")?String.valueOf(queues.getJSONObject(i).getInt("messages_unacknowledged")):"0");
rabbitMQ.setTotal(queues.getJSONObject(i).has("messages")?String.valueOf(queues.getJSONObject(i).getInt("messages")):"0");
rabbitMQList.add(rabbitMQ);