git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1406186 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2012-11-06 15:37:50 +00:00
parent 1942324dc3
commit 19622d36a6
1 changed files with 15 additions and 5 deletions

View File

@ -22,7 +22,6 @@ import java.util.Set;
import javax.jms.JMSException; import javax.jms.JMSException;
import javax.management.ObjectName; import javax.management.ObjectName;
import org.apache.activemq.advisory.AdvisorySupport; import org.apache.activemq.advisory.AdvisorySupport;
import org.apache.activemq.broker.Broker; import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerFilter; import org.apache.activemq.broker.BrokerFilter;
@ -58,6 +57,7 @@ public class StatisticsBroker extends BrokerFilter {
static final String STATS_BROKER_PREFIX = "ActiveMQ.Statistics.Broker"; static final String STATS_BROKER_PREFIX = "ActiveMQ.Statistics.Broker";
static final String STATS_BROKER_RESET_HEADER = "ActiveMQ.Statistics.Broker.Reset"; static final String STATS_BROKER_RESET_HEADER = "ActiveMQ.Statistics.Broker.Reset";
static final String STATS_SUBSCRIPTION_PREFIX = "ActiveMQ.Statistics.Subscription"; static final String STATS_SUBSCRIPTION_PREFIX = "ActiveMQ.Statistics.Subscription";
static final String STATS_DENOTE_END_LIST = STATS_DESTINATION_PREFIX + ".List.End.With.Null";
private static final IdGenerator ID_GENERATOR = new IdGenerator(); private static final IdGenerator ID_GENERATOR = new IdGenerator();
private final LongSequenceGenerator messageIdGenerator = new LongSequenceGenerator(); private final LongSequenceGenerator messageIdGenerator = new LongSequenceGenerator();
protected final ProducerId advisoryProducerId = new ProducerId(); protected final ProducerId advisoryProducerId = new ProducerId();
@ -94,10 +94,13 @@ public class StatisticsBroker extends BrokerFilter {
BrokerService brokerService = getBrokerService(); BrokerService brokerService = getBrokerService();
RegionBroker regionBroker = (RegionBroker) brokerService.getRegionBroker(); RegionBroker regionBroker = (RegionBroker) brokerService.getRegionBroker();
if (destStats) { if (destStats) {
String queueryName = physicalName.substring(STATS_DESTINATION_PREFIX.length(), physicalName.length()); String destinationName = physicalName.substring(STATS_DESTINATION_PREFIX.length(), physicalName.length());
ActiveMQDestination queryDest = ActiveMQDestination.createDestination(queueryName,msgDest.getDestinationType()); String destinationQuery = destinationName.replace(STATS_DENOTE_END_LIST,"");
Set<Destination> set = getDestinations(queryDest); boolean endListMessage = !destinationName.equals(destinationQuery);
for (Destination dest : set) { ActiveMQDestination queryDestination = ActiveMQDestination.createDestination(destinationQuery,msgDest.getDestinationType());
Set<Destination> destinations = getDestinations(queryDestination);
for (Destination dest : destinations) {
DestinationStatistics stats = dest.getDestinationStatistics(); DestinationStatistics stats = dest.getDestinationStatistics();
if (stats != null) { if (stats != null) {
ActiveMQMapMessage statsMessage = new ActiveMQMapMessage(); ActiveMQMapMessage statsMessage = new ActiveMQMapMessage();
@ -121,6 +124,12 @@ public class StatisticsBroker extends BrokerFilter {
sendStats(producerExchange.getConnectionContext(), statsMessage, replyTo); sendStats(producerExchange.getConnectionContext(), statsMessage, replyTo);
} }
} }
if(endListMessage){
ActiveMQMapMessage statsMessage = new ActiveMQMapMessage();
statsMessage.setJMSCorrelationID(messageSend.getCorrelationId());
sendStats(producerExchange.getConnectionContext(),statsMessage,replyTo);
}
} else if (subStats) { } else if (subStats) {
sendSubStats(producerExchange.getConnectionContext(), getBrokerView().getQueueSubscribers(), replyTo); sendSubStats(producerExchange.getConnectionContext(), getBrokerView().getQueueSubscribers(), replyTo);
sendSubStats(producerExchange.getConnectionContext(), getBrokerView().getTopicSubscribers(), replyTo); sendSubStats(producerExchange.getConnectionContext(), getBrokerView().getTopicSubscribers(), replyTo);
@ -250,4 +259,5 @@ public class StatisticsBroker extends BrokerFilter {
context.setProducerFlowControl(originalFlowControl); context.setProducerFlowControl(originalFlowControl);
} }
} }
} }