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() && !queue.getName().startsWith(ResourceNames.JMS_TOPIC))
{
Pair<String, String> pair = HornetQDestination.decomposeQueueNameForDurableSubscription(queue.getName()
.toString());
clientID = pair.getA();
subName = pair.getB();
}
else if (queue.getName().startsWith(ResourceNames.JMS_TOPIC))
{
// in the case of heirarchical topics the queue name will not follow the <part>.<part> pattern of normal
// durable subscribers so skip decomposing the name for the client ID and subscription name and just
// hard-code it
clientID = "HornetQ";
subName = "HornetQ";
}
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();