boolean brokerStats = physicalName.regionMatches(true, 0, STATS_BROKER_PREFIX, 0, STATS_BROKER_PREFIX
.length());
boolean subStats = physicalName.regionMatches(true, 0, STATS_SUBSCRIPTION_PREFIX, 0, STATS_SUBSCRIPTION_PREFIX
.length());
BrokerService brokerService = getBrokerService();
RegionBroker regionBroker = (RegionBroker) brokerService.getRegionBroker();
if (destStats) {
String destinationName = physicalName.substring(STATS_DESTINATION_PREFIX.length(), physicalName.length());
String destinationQuery = destinationName.replace(STATS_DENOTE_END_LIST,"");
boolean endListMessage = !destinationName.equals(destinationQuery);
ActiveMQDestination queryDestination = ActiveMQDestination.createDestination(destinationQuery,msgDest.getDestinationType());
Set<Destination> destinations = getDestinations(queryDestination);
for (Destination dest : destinations) {
DestinationStatistics stats = dest.getDestinationStatistics();
if (stats != null) {
ActiveMQMapMessage statsMessage = new ActiveMQMapMessage();
statsMessage.setString("destinationName", dest.getActiveMQDestination().toString());
statsMessage.setLong("size", stats.getMessages().getCount());
statsMessage.setLong("enqueueCount", stats.getEnqueues().getCount());
statsMessage.setLong("dequeueCount", stats.getDequeues().getCount());
statsMessage.setLong("dispatchCount", stats.getDispatched().getCount());
statsMessage.setLong("expiredCount", stats.getExpired().getCount());
statsMessage.setLong("inflightCount", stats.getInflight().getCount());
statsMessage.setLong("messagesCached", stats.getMessagesCached().getCount());
statsMessage.setInt("memoryPercentUsage", dest.getMemoryUsage().getPercentUsage());
statsMessage.setLong("memoryUsage", dest.getMemoryUsage().getUsage());
statsMessage.setLong("memoryLimit", dest.getMemoryUsage().getLimit());
statsMessage.setDouble("averageEnqueueTime", stats.getProcessTime().getAverageTime());
statsMessage.setDouble("maxEnqueueTime", stats.getProcessTime().getMaxTime());
statsMessage.setDouble("minEnqueueTime", stats.getProcessTime().getMinTime());
statsMessage.setLong("consumerCount", stats.getConsumers().getCount());
statsMessage.setLong("producerCount", stats.getProducers().getCount());
statsMessage.setJMSCorrelationID(messageSend.getCorrelationId());
sendStats(producerExchange.getConnectionContext(), statsMessage, replyTo);
}
}
if(endListMessage){
ActiveMQMapMessage statsMessage = new ActiveMQMapMessage();
statsMessage.setJMSCorrelationID(messageSend.getCorrelationId());
sendStats(producerExchange.getConnectionContext(),statsMessage,replyTo);
}
} else if (subStats) {
sendSubStats(producerExchange.getConnectionContext(), getBrokerView().getQueueSubscribers(), replyTo);
sendSubStats(producerExchange.getConnectionContext(), getBrokerView().getTopicSubscribers(), replyTo);
} else if (brokerStats) {
if (messageSend.getProperties().containsKey(STATS_BROKER_RESET_HEADER)) {
getBrokerView().resetStatistics();
}
ActiveMQMapMessage statsMessage = new ActiveMQMapMessage();
SystemUsage systemUsage = brokerService.getSystemUsage();
DestinationStatistics stats = regionBroker.getDestinationStatistics();
statsMessage.setString("brokerName", regionBroker.getBrokerName());
statsMessage.setString("brokerId", regionBroker.getBrokerId().toString());
statsMessage.setLong("size", stats.getMessages().getCount());
statsMessage.setLong("enqueueCount", stats.getEnqueues().getCount());
statsMessage.setLong("dequeueCount", stats.getDequeues().getCount());
statsMessage.setLong("dispatchCount", stats.getDispatched().getCount());
statsMessage.setLong("expiredCount", stats.getExpired().getCount());