/* (non-Javadoc) * @see org.hornetq.api.core.management.QueueControl#listConsumersAsJSON() */ public String listConsumersAsJSON() throws Exception { checkStarted(); clearIO(); try { Collection<Consumer> consumers = queue.getConsumers(); JSONArray jsonArray = new JSONArray(); for (Consumer consumer : consumers) { if (consumer instanceof ServerConsumer) { ServerConsumer serverConsumer = (ServerConsumer) consumer; JSONObject obj = new JSONObject(); obj.put("consumerID", serverConsumer.getID()); obj.put("connectionID", serverConsumer.getConnectionID().toString()); obj.put("sessionID", serverConsumer.getSessionID()); obj.put("browseOnly", serverConsumer.isBrowseOnly()); obj.put("creationTime", serverConsumer.getCreationTime()); jsonArray.put(obj); } } return jsonArray.toString(); } finally { blockOnIO(); } }
public static String toJSON(final DayCounterInfo[] infos) throws JSONException { JSONObject json = new JSONObject(); JSONArray counters = new JSONArray(); for (DayCounterInfo info : infos) { JSONObject counter = new JSONObject(); counter.put("date", info.getDate()); counter.put("counters", Arrays.asList(info.getCounters())); counters.put(counter); } json.put("dayCounters", counters); return json.toString(); }
/* (non-Javadoc) * @see org.hornetq.core.server.ServerSession#getProducersInfoJSON() */ public void describeProducersInfo(JSONArray array) throws Exception { Map<SimpleString, Pair<UUID, AtomicLong>> targetCopy = cloneTargetAddresses(); for (Map.Entry<SimpleString, Pair<UUID, AtomicLong>> entry : targetCopy.entrySet()) { JSONObject producerInfo = new JSONObject(); producerInfo.put("connectionID", this.getConnectionID().toString()); producerInfo.put("sessionID", this.getName()); producerInfo.put("destination", entry.getKey().toString()); producerInfo.put("lastUUIDSent", entry.getValue().getA()); producerInfo.put("msgSent", entry.getValue().getB().longValue()); array.put(producerInfo); } }