private String listSubscribersInfosAsJSON(final DurabilityType durability) throws Exception
{
try
{
List<QueueControl> queues = getQueues(durability);
JSONArray array = new JSONArray();
for (QueueControl queue : queues)
{
String clientID = null;
String subName = null;
if (queue.isDurable())
{
Pair<String, String> pair = HornetQDestination.decomposeQueueNameForDurableSubscription(queue.getName()
.toString());
clientID = pair.a;
subName = pair.b;
}
String filter = queue.getFilter() != null ? queue.getFilter() : null;
JSONObject info = new JSONObject();
info.put("queueName", queue.getName());
info.put("clientID", clientID);
info.put("selector", filter);
info.put("name", subName);
info.put("durable", queue.isDurable());
info.put("messageCount", queue.getMessageCount());
info.put("deliveringCount", queue.getDeliveringCount());
info.put("consumers", new JSONArray(queue.listConsumersAsJSON()) );
array.put(info);
}
return array.toString();
}
catch (Exception e)
{
e.printStackTrace();
return e.toString();