You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ma...@apache.org on 2024/09/20 13:48:29 UTC

(activemq) 02/02: TODO: This commit will be squashed after reviews

This is an automated email from the ASF dual-hosted git repository.

mattrpav pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq.git

commit f34a6601ea6ef81f7473ac2e69f6122a6ac28f4c
Author: Matt Pavlovich <ma...@apache.org>
AuthorDate: Mon Sep 16 10:09:35 2024 -0500

    TODO: This commit will be squashed after reviews
    
    - Rename to advancedNetworkStatistics
    - Add unit test to cover queue and topic use case
    - Improve unit tests to confirm network stats do not incorrectly increment on non-network enqueue/dequeue
---
 .../apache/activemq/broker/TransactionBroker.java  |  12 +--
 .../activemq/broker/jmx/DestinationView.java       |   8 +-
 .../activemq/broker/jmx/DestinationViewMBean.java  |   8 +-
 .../activemq/broker/region/BaseDestination.java    |  10 +-
 .../apache/activemq/broker/region/Destination.java |   4 +-
 .../activemq/broker/region/DestinationFilter.java  |   8 +-
 .../broker/region/DurableTopicSubscription.java    |   2 +-
 .../org/apache/activemq/broker/region/Queue.java   |   4 +-
 .../org/apache/activemq/broker/region/Topic.java   |   2 +-
 .../activemq/broker/region/TopicSubscription.java  |   4 +-
 .../activemq/broker/region/policy/PolicyEntry.java |  14 +--
 .../java/org/apache/activemq/PolicyEntryTest.java  |  14 +--
 ...yTest-policy-advancedNetworkStatistics-mod.xml} |   2 +-
 ...EntryTest-policy-advancedNetworkStatistics.xml} |   0
 .../network/NetworkAdvancedStatisticsTest.java     | 105 ++++++++++++++++-----
 ...l => localBroker-advancedNetworkStatistics.xml} |   8 +-
 ... => remoteBroker-advancedNetworkStatistics.xml} |   8 +-
 17 files changed, 135 insertions(+), 78 deletions(-)

diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/TransactionBroker.java b/activemq-broker/src/main/java/org/apache/activemq/broker/TransactionBroker.java
index fbee030885..c8af4a6144 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/TransactionBroker.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/TransactionBroker.java
@@ -191,18 +191,14 @@ public class TransactionBroker extends BrokerFilter {
                 dest.getDestinationStatistics().getEnqueues().add(opCount);
                 dest.getDestinationStatistics().getMessages().add(opCount);
 
-                if(dest.isAdvancedStatisticsEnabled()) {
-                    if(transactionBroker.context.isNetworkConnection()) {
-                        dest.getDestinationStatistics().getNetworkEnqueues().add(opCount);
-                    }
+                if(dest.isAdvancedNetworkStatisticsEnabled() && transactionBroker.context != null && transactionBroker.context.isNetworkConnection()) {
+                    dest.getDestinationStatistics().getNetworkEnqueues().add(opCount);
                 }
                 LOG.debug("cleared pending from afterCommit: {}", destination);
             } else {
                 dest.getDestinationStatistics().getDequeues().add(opCount);
-                if(dest.isAdvancedStatisticsEnabled()) {
-                    if(transactionBroker.context.isNetworkConnection()) {
-                        dest.getDestinationStatistics().getNetworkDequeues().add(opCount);
-                    }
+                if(dest.isAdvancedNetworkStatisticsEnabled() && transactionBroker.context != null && transactionBroker.context.isNetworkConnection()) {
+                    dest.getDestinationStatistics().getNetworkDequeues().add(opCount);
                 }
             }
         }
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
index 1b05a768d4..02a7f65057 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
@@ -601,13 +601,13 @@ public class DestinationView implements DestinationViewMBean {
     }
 
     @Override
-    public boolean isAdvancedStatisticsEnabled() {
-        return destination.isAdvancedStatisticsEnabled();
+    public boolean isAdvancedNetworkStatisticsEnabled() {
+        return destination.isAdvancedNetworkStatisticsEnabled();
     }
 
     @Override
-    public void setAdvancedStatisticsEnabled(boolean advancedStatisticsEnabled) {
-        destination.setAdvancedStatisticsEnabled(advancedStatisticsEnabled);
+    public void setAdvancedNetworkStatisticsEnabled(boolean advancedNetworkStatisticsEnabled) {
+        destination.setAdvancedNetworkStatisticsEnabled(advancedNetworkStatisticsEnabled);
     }
 
     @Override
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
index db518f78b6..328ddb09f0 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
@@ -482,11 +482,11 @@ public interface DestinationViewMBean {
     @MBeanInfo("Number of times the max uncommitted limit has been exceed for this destination")
     long getMaxUncommittedExceededCount();
 
-    @MBeanInfo("Query Advanced Statistics flag")
-    boolean isAdvancedStatisticsEnabled();
+    @MBeanInfo("Query Advanced Network Statistics flag")
+    boolean isAdvancedNetworkStatisticsEnabled();
 
-    @MBeanInfo("Toggle Advanced Statistics flag")
-    void setAdvancedStatisticsEnabled(boolean advancedStatisticsEnabled);
+    @MBeanInfo("Toggle Advanced Network Statistics flag")
+    void setAdvancedNetworkStatisticsEnabled(boolean advancedNetworkStatisticsEnabled);
 
     @MBeanInfo("Number of messages sent to the destination via network connection")
     long getNetworkEnqueues();
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java
index 3964a8ce92..e34f23a4dd 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java
@@ -110,7 +110,7 @@ public abstract class BaseDestination implements Destination {
     protected final Scheduler scheduler;
     private boolean disposed = false;
     private boolean doOptimzeMessageStorage = true;
-    private boolean advancedStatisticsEnabled = false;
+    private boolean advancedNetworkStatisticsEnabled = false;
 
     /*
      * percentage of in-flight messages above which optimize message store is disabled
@@ -871,13 +871,13 @@ public abstract class BaseDestination implements Destination {
     }
 
     @Override
-    public boolean isAdvancedStatisticsEnabled() {
-        return this.advancedStatisticsEnabled;
+    public boolean isAdvancedNetworkStatisticsEnabled() {
+        return this.advancedNetworkStatisticsEnabled;
     }
 
     @Override
-    public void setAdvancedStatisticsEnabled(boolean advancedStatisticsEnabled) {
-        this.advancedStatisticsEnabled = advancedStatisticsEnabled;
+    public void setAdvancedNetworkStatisticsEnabled(boolean advancedNetworkStatisticsEnabled) {
+        this.advancedNetworkStatisticsEnabled = advancedNetworkStatisticsEnabled;
     }
 
     @Override
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Destination.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Destination.java
index de36f1605a..45e3de7b3c 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Destination.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Destination.java
@@ -260,8 +260,8 @@ public interface Destination extends Service, Task, Message.MessageDestination {
     void setSendDuplicateFromStoreToDLQ(boolean sendDuplicateFromStoreToDLQ);
 
     // [AMQ-9437]
-    boolean isAdvancedStatisticsEnabled();
+    boolean isAdvancedNetworkStatisticsEnabled();
 
-    void setAdvancedStatisticsEnabled(boolean advancedStatisticsEnabled);
+    void setAdvancedNetworkStatisticsEnabled(boolean advancedNetworkStatisticsEnabled);
 
 }
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java
index cfc1de4509..85ef367a77 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java
@@ -410,13 +410,13 @@ public class DestinationFilter implements Destination {
     }
 
     @Override
-    public boolean isAdvancedStatisticsEnabled() {
-        return next.isAdvancedStatisticsEnabled();
+    public boolean isAdvancedNetworkStatisticsEnabled() {
+        return next.isAdvancedNetworkStatisticsEnabled();
     }
 
     @Override
-    public void setAdvancedStatisticsEnabled(boolean advancedStatisticsEnabled) {
-        next.setAdvancedStatisticsEnabled(advancedStatisticsEnabled);
+    public void setAdvancedNetworkStatisticsEnabled(boolean advancedNetworkStatisticsEnabled) {
+        next.setAdvancedNetworkStatisticsEnabled(advancedNetworkStatisticsEnabled);
     }
 
     public void deleteSubscription(ConnectionContext context, SubscriptionKey key) throws Exception {
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java
index c1cfe00d71..6946a33fa5 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java
@@ -371,7 +371,7 @@ public class DurableTopicSubscription extends PrefetchSubscription implements Us
         ((Destination)node.getRegionDestination()).getDestinationStatistics().getDequeues().increment();
         if (info.isNetworkSubscription()) {
             ((Destination)node.getRegionDestination()).getDestinationStatistics().getForwards().add(ack.getMessageCount());
-            if(((Destination)node.getRegionDestination()).isAdvancedStatisticsEnabled()) {
+            if(((Destination)node.getRegionDestination()).isAdvancedNetworkStatisticsEnabled() && getContext() != null && getContext().isNetworkConnection()) {
                 ((Destination)node.getRegionDestination()).getDestinationStatistics().getNetworkDequeues().add(ack.getMessageCount());
             }
         }
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
index 4bbbefab54..0ed6763f7b 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
@@ -1916,7 +1916,7 @@ public class Queue extends BaseDestination implements Task, UsageListener, Index
             getDestinationStatistics().getDequeues().increment();
             getDestinationStatistics().getMessages().decrement();
 
-            if(context.getConnection().isNetworkConnection() && isAdvancedStatisticsEnabled()) {
+            if(isAdvancedNetworkStatisticsEnabled() && context.getConnection() != null && context.getConnection().isNetworkConnection()) {
                 getDestinationStatistics().getNetworkDequeues().increment();
             }
 
@@ -1975,7 +1975,7 @@ public class Queue extends BaseDestination implements Task, UsageListener, Index
         destinationStatistics.getMessages().increment();
         destinationStatistics.getMessageSize().addSize(msg.getSize());
 
-        if(context.getConnection().isNetworkConnection() && isAdvancedStatisticsEnabled()) {
+        if(isAdvancedNetworkStatisticsEnabled() && context.getConnection() != null && context.getConnection().isNetworkConnection()) {
             destinationStatistics.getNetworkEnqueues().increment();
         }
 
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java
index 1c394f2ff9..a9e07874e0 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java
@@ -779,7 +779,7 @@ public class Topic extends BaseDestination implements Task {
         // destinationStatistics.getMessages().increment();
         destinationStatistics.getEnqueues().increment();
 
-        if(context.isNetworkConnection() && isAdvancedStatisticsEnabled()) {
+        if(isAdvancedNetworkStatisticsEnabled() && context != null && context.isNetworkConnection()) {
             destinationStatistics.getNetworkEnqueues().increment();
         }
 
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java
index 84835a7169..4403dea6b5 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java
@@ -449,7 +449,7 @@ public class TopicSubscription extends AbstractSubscription {
         destination.getDestinationStatistics().getInflight().subtract(count);
         if (info.isNetworkSubscription()) {
             destination.getDestinationStatistics().getForwards().add(count);
-            if(destination.isAdvancedStatisticsEnabled()) {
+            if(destination.isAdvancedNetworkStatisticsEnabled() && getContext() != null && getContext().isNetworkConnection()) {
                 destination.getDestinationStatistics().getNetworkDequeues().add(count);
             }
         }
@@ -749,7 +749,7 @@ public class TopicSubscription extends AbstractSubscription {
             matched.remove(message);
             if (destination != null) {
                 destination.getDestinationStatistics().getDequeues().increment();
-                if(destination.isAdvancedStatisticsEnabled()) {
+                if(destination.isAdvancedNetworkStatisticsEnabled() && getContext() != null && getContext().isNetworkConnection()) {
                     destination.getDestinationStatistics().getNetworkDequeues().increment();
                 }
             }
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java
index 620daf2a60..e33f13b48c 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/PolicyEntry.java
@@ -106,7 +106,7 @@ public class PolicyEntry extends DestinationMapEntry {
     private boolean doOptimzeMessageStorage = true;
     private int maxDestinations = -1;
     private boolean useTopicSubscriptionInflightStats = true;
-    private boolean advancedStatisticsEnabled = false; // [AMQ-9437]
+    private boolean advancedNetworkStatisticsEnabled = false; // [AMQ-9437]
     /*
      * percentage of in-flight messages above which optimize message store is disabled
      */
@@ -306,8 +306,8 @@ public class PolicyEntry extends DestinationMapEntry {
         if (isUpdate("sendDuplicateFromStoreToDLQ", includedProperties)) {
             destination.setSendDuplicateFromStoreToDLQ(isSendDuplicateFromStoreToDLQ());
         }
-        if (isUpdate("advancedStatisticsEnabled", includedProperties)) {
-            destination.setAdvancedStatisticsEnabled(isAdvancedStatisticsEnabled());
+        if (isUpdate("advancedNetworkStatisticsEnabled", includedProperties)) {
+            destination.setAdvancedNetworkStatisticsEnabled(isAdvancedNetworkStatisticsEnabled());
         }
     }
 
@@ -1180,11 +1180,11 @@ public class PolicyEntry extends DestinationMapEntry {
         return this.messageInterceptorStrategy;
     } 
 
-    public boolean isAdvancedStatisticsEnabled() {
-        return this.advancedStatisticsEnabled;
+    public boolean isAdvancedNetworkStatisticsEnabled() {
+        return this.advancedNetworkStatisticsEnabled;
     }
 
-    public void setAdvancedStatisticsEnabled(boolean advancedStatisticsEnabled) {
-        this.advancedStatisticsEnabled = advancedStatisticsEnabled;
+    public void setAdvancedNetworkStatisticsEnabled(boolean advancedNetworkStatisticsEnabled) {
+        this.advancedNetworkStatisticsEnabled = advancedNetworkStatisticsEnabled;
     }
 }
diff --git a/activemq-runtime-config/src/test/java/org/apache/activemq/PolicyEntryTest.java b/activemq-runtime-config/src/test/java/org/apache/activemq/PolicyEntryTest.java
index 83fdc145c4..53341c3a53 100644
--- a/activemq-runtime-config/src/test/java/org/apache/activemq/PolicyEntryTest.java
+++ b/activemq-runtime-config/src/test/java/org/apache/activemq/PolicyEntryTest.java
@@ -58,15 +58,15 @@ public class PolicyEntryTest extends RuntimeConfigTestSupport {
     }
 
     @Test
-    public void testModAdvancedStatistics() throws Exception {
+    public void testModAdvancedNetworkStatistics() throws Exception {
         final String brokerConfig = configurationSeed + "-policy-ml-broker";
-        applyNewConfig(brokerConfig, configurationSeed + "-policy-advancedStatistics");
+        applyNewConfig(brokerConfig, configurationSeed + "-policy-advancedNetworkStatistics");
         startBroker(brokerConfig);
         assertTrue("broker alive", brokerService.isStarted());
 
-        verifyBooleanField("AMQ.9437", "advancedStatisticsEnabled", false);
-        applyNewConfig(brokerConfig, configurationSeed + "-policy-advancedStatistics-mod", SLEEP);
-        verifyBooleanField("AMQ.9437", "advancedStatisticsEnabled", true);
+        verifyBooleanField("AMQ.9437", "advancedNetworkStatisticsEnabled", false);
+        applyNewConfig(brokerConfig, configurationSeed + "-policy-advancedNetworkStatistics-mod", SLEEP);
+        verifyBooleanField("AMQ.9437", "advancedNetworkStatisticsEnabled", true);
     }
 
     @Test
@@ -133,8 +133,8 @@ public class PolicyEntryTest extends RuntimeConfigTestSupport {
             session.createConsumer(session.createQueue(dest));
 
             switch(fieldName) {
-            case "advancedStatisticsEnabled":
-                assertEquals(value, brokerService.getRegionBroker().getDestinationMap().get(new ActiveMQQueue(dest)).isAdvancedStatisticsEnabled());
+            case "advancedNetworkStatisticsEnabled":
+                assertEquals(value, brokerService.getRegionBroker().getDestinationMap().get(new ActiveMQQueue(dest)).isAdvancedNetworkStatisticsEnabled());
                 break;
             case "sendDuplicateFromStoreToDLQ":
                 assertEquals(value, brokerService.getRegionBroker().getDestinationMap().get(new ActiveMQQueue(dest)).isSendDuplicateFromStoreToDLQ());
diff --git a/activemq-runtime-config/src/test/resources/org/apache/activemq/policyEntryTest-policy-advancedStatistics-mod.xml b/activemq-runtime-config/src/test/resources/org/apache/activemq/policyEntryTest-policy-advancedNetworkStatistics-mod.xml
similarity index 94%
rename from activemq-runtime-config/src/test/resources/org/apache/activemq/policyEntryTest-policy-advancedStatistics-mod.xml
rename to activemq-runtime-config/src/test/resources/org/apache/activemq/policyEntryTest-policy-advancedNetworkStatistics-mod.xml
index d5a44a27c9..534f884d4b 100644
--- a/activemq-runtime-config/src/test/resources/org/apache/activemq/policyEntryTest-policy-advancedStatistics-mod.xml
+++ b/activemq-runtime-config/src/test/resources/org/apache/activemq/policyEntryTest-policy-advancedNetworkStatistics-mod.xml
@@ -28,7 +28,7 @@
     <destinationPolicy>
       <policyMap>
         <policyEntries>
-          <policyEntry queue="AMQ.9437" advancedStatisticsEnabled="true"/>
+          <policyEntry queue="AMQ.9437" advancedNetworkStatisticsEnabled="true"/>
         </policyEntries>
       </policyMap>
     </destinationPolicy>
diff --git a/activemq-runtime-config/src/test/resources/org/apache/activemq/policyEntryTest-policy-advancedStatistics.xml b/activemq-runtime-config/src/test/resources/org/apache/activemq/policyEntryTest-policy-advancedNetworkStatistics.xml
similarity index 100%
rename from activemq-runtime-config/src/test/resources/org/apache/activemq/policyEntryTest-policy-advancedStatistics.xml
rename to activemq-runtime-config/src/test/resources/org/apache/activemq/policyEntryTest-policy-advancedNetworkStatistics.xml
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java
index f5c90e589d..df99bab354 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/network/NetworkAdvancedStatisticsTest.java
@@ -19,41 +19,61 @@ package org.apache.activemq.network;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+
+import java.util.Arrays;
+import java.util.Collection;
+
 import jakarta.jms.Message;
 import jakarta.jms.MessageConsumer;
+import jakarta.jms.MessageListener;
 import jakarta.jms.MessageProducer;
 
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTopic;
 import org.apache.activemq.util.Wait;
 import org.apache.activemq.util.Wait.Condition;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 import org.springframework.context.support.AbstractApplicationContext;
 
+@RunWith(value = Parameterized.class)
 public class NetworkAdvancedStatisticsTest extends BaseNetworkTest {
 
+    @Parameterized.Parameters(name="includedDestination={0}, excludedDestination={1}")
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] {
+                { new ActiveMQTopic("include.test.bar"), new ActiveMQTopic("exclude.test.bar")},
+                { new ActiveMQQueue("include.test.foo"), new ActiveMQQueue("exclude.test.foo")}});
+    }
+
     protected static final int MESSAGE_COUNT = 10;
 
     protected AbstractApplicationContext context;
-    protected ActiveMQTopic included;
-    protected ActiveMQTopic excluded;
     protected String consumerName = "durableSubs";
 
+    private final ActiveMQDestination includedDestination;
+    private final ActiveMQDestination excludedDestination;
+
+    public NetworkAdvancedStatisticsTest(ActiveMQDestination includedDestionation, ActiveMQDestination excludedDestination) {
+        this.includedDestination = includedDestionation;
+        this.excludedDestination = excludedDestination;
+    }
+
     @Override
     protected void doSetUp(boolean deleteAllMessages) throws Exception {
         super.doSetUp(deleteAllMessages);
-
-        included = new ActiveMQTopic("include.test.bar");
-        excluded = new ActiveMQTopic("exclude.test.bar");
     }
 
     @Override
     protected String getRemoteBrokerURI() {
-        return "org/apache/activemq/network/remoteBroker-advancedStatistics.xml";
+        return "org/apache/activemq/network/remoteBroker-advancedNetworkStatistics.xml";
     }
 
     @Override
     protected String getLocalBrokerURI() {
-        return "org/apache/activemq/network/localBroker-advancedStatistics.xml";
+        return "org/apache/activemq/network/localBroker-advancedNetworkStatistics.xml";
     }
 
     //Added for AMQ-9437 test advancedStatistics for networkEnqueue and networkDequeue
@@ -61,30 +81,71 @@ public class NetworkAdvancedStatisticsTest extends BaseNetworkTest {
     public void testNetworkAdvancedStatistics() throws Exception {
 
         // create a remote durable consumer to create demand
-        MessageConsumer remoteConsumer = remoteSession.createDurableSubscriber(included, consumerName);
+        MessageConsumer remoteConsumer;
+        if(includedDestination.isTopic()) {
+            remoteConsumer = remoteSession.createDurableSubscriber(ActiveMQTopic.class.cast(includedDestination), consumerName);
+        } else {
+            remoteConsumer = remoteSession.createConsumer(includedDestination);
+            remoteConsumer.setMessageListener(new MessageListener() {                
+                @Override
+                public void onMessage(Message message) {
+                }
+            });
+        }
         Thread.sleep(1000);
 
-        MessageProducer producer = localSession.createProducer(included);
+        MessageProducer producer = localSession.createProducer(includedDestination);
         for (int i = 0; i < MESSAGE_COUNT; i++) {
             Message test = localSession.createTextMessage("test-" + i);
             producer.send(test);
         }
         Thread.sleep(1000);
 
-        //Make sure stats are correct for local -> remote
-        assertEquals(MESSAGE_COUNT, localBroker.getDestination(included).getDestinationStatistics().getForwards().getCount());
-        assertEquals(MESSAGE_COUNT, localBroker.getDestination(included).getDestinationStatistics().getNetworkDequeues().getCount());
-        assertEquals(0, localBroker.getDestination(included).getDestinationStatistics().getNetworkEnqueues().getCount());
-        assertEquals(MESSAGE_COUNT, remoteBroker.getDestination(included).getDestinationStatistics().getNetworkEnqueues().getCount());
-        assertEquals(0, remoteBroker.getDestination(included).getDestinationStatistics().getNetworkDequeues().getCount());
-
-        assertTrue(Wait.waitFor(new Condition() {
+        MessageProducer producerExcluded = localSession.createProducer(excludedDestination);
+        for (int i = 0; i < MESSAGE_COUNT; i++) {
+            Message test = localSession.createTextMessage("test-" + i);
+            producerExcluded.send(test);
+        }
+        Thread.sleep(1000);
 
-            @Override
-            public boolean isSatisified() throws Exception {
-                return localBroker.getSystemUsage().getMemoryUsage().getUsage() == 0;
-            }
-        }, 10000, 500));
+        //Make sure stats are correct for local -> remote
+        assertEquals(MESSAGE_COUNT, localBroker.getDestination(includedDestination).getDestinationStatistics().getEnqueues().getCount());
+        assertEquals(MESSAGE_COUNT, localBroker.getDestination(includedDestination).getDestinationStatistics().getDequeues().getCount());
+        assertEquals(MESSAGE_COUNT, localBroker.getDestination(includedDestination).getDestinationStatistics().getForwards().getCount());
+        assertEquals(MESSAGE_COUNT, localBroker.getDestination(includedDestination).getDestinationStatistics().getNetworkDequeues().getCount());
+        assertEquals(0, localBroker.getDestination(includedDestination).getDestinationStatistics().getNetworkEnqueues().getCount());
+        assertEquals(MESSAGE_COUNT, remoteBroker.getDestination(includedDestination).getDestinationStatistics().getEnqueues().getCount());
+        assertEquals(0, remoteBroker.getDestination(includedDestination).getDestinationStatistics().getForwards().getCount());
+        assertEquals(MESSAGE_COUNT, remoteBroker.getDestination(includedDestination).getDestinationStatistics().getNetworkEnqueues().getCount());
+        assertEquals(0, remoteBroker.getDestination(includedDestination).getDestinationStatistics().getNetworkDequeues().getCount());
+
+        // Make sure stats do not increment for local-only
+        assertEquals(MESSAGE_COUNT, localBroker.getDestination(excludedDestination).getDestinationStatistics().getEnqueues().getCount());
+        assertEquals(0, localBroker.getDestination(excludedDestination).getDestinationStatistics().getForwards().getCount());
+        assertEquals(0, localBroker.getDestination(excludedDestination).getDestinationStatistics().getNetworkDequeues().getCount());
+        assertEquals(0, localBroker.getDestination(excludedDestination).getDestinationStatistics().getNetworkEnqueues().getCount());
+        assertEquals(0, remoteBroker.getDestination(excludedDestination).getDestinationStatistics().getEnqueues().getCount());
+        assertEquals(0, remoteBroker.getDestination(excludedDestination).getDestinationStatistics().getDequeues().getCount());
+        assertEquals(0, remoteBroker.getDestination(excludedDestination).getDestinationStatistics().getForwards().getCount());
+        assertEquals(0, remoteBroker.getDestination(excludedDestination).getDestinationStatistics().getNetworkEnqueues().getCount());
+        assertEquals(0, remoteBroker.getDestination(excludedDestination).getDestinationStatistics().getNetworkDequeues().getCount());
+
+        if(includedDestination.isTopic()) {
+            assertTrue(Wait.waitFor(new Condition() {
+                @Override
+                public boolean isSatisified() throws Exception {
+                    return localBroker.getSystemUsage().getMemoryUsage().getUsage() == 0;
+                }
+            }, 10000, 500));
+        } else {
+            assertTrue(Wait.waitFor(new Condition() {
+                @Override
+                public boolean isSatisified() throws Exception {
+                    // The number of message that remain is due to the exclude queue
+                    return localBroker.getAdminView().getTotalMessageCount() == MESSAGE_COUNT;
+                }
+            }, 10000, 500));
+        }
         remoteConsumer.close();
     }
 
diff --git a/activemq-unit-tests/src/test/resources/org/apache/activemq/network/localBroker-advancedStatistics.xml b/activemq-unit-tests/src/test/resources/org/apache/activemq/network/localBroker-advancedNetworkStatistics.xml
similarity index 88%
rename from activemq-unit-tests/src/test/resources/org/apache/activemq/network/localBroker-advancedStatistics.xml
rename to activemq-unit-tests/src/test/resources/org/apache/activemq/network/localBroker-advancedNetworkStatistics.xml
index b5c67e2d39..b543169f6e 100644
--- a/activemq-unit-tests/src/test/resources/org/apache/activemq/network/localBroker-advancedStatistics.xml
+++ b/activemq-unit-tests/src/test/resources/org/apache/activemq/network/localBroker-advancedNetworkStatistics.xml
@@ -28,11 +28,11 @@
     <destinationPolicy>
       <policyMap>
         <policyEntries>
-          <policyEntry queue="exclude.>" advancedStatisticsEnabled="true"/>
-          <policyEntry queue="include.>" advancedStatisticsEnabled="true"/> 
+          <policyEntry queue="exclude.>" advancedNetworkStatisticsEnabled="true"/>
+          <policyEntry queue="include.>" advancedNetworkStatisticsEnabled="true"/> 
           <policyEntry topic="ActiveMQ.Advisory.>" />
-          <policyEntry topic="exclude.>" advancedStatisticsEnabled="true"/>
-          <policyEntry topic="include.>" advancedStatisticsEnabled="true"/> 
+          <policyEntry topic="exclude.>" advancedNetworkStatisticsEnabled="true"/>
+          <policyEntry topic="include.>" advancedNetworkStatisticsEnabled="true"/> 
         </policyEntries>
       </policyMap>
     </destinationPolicy>
diff --git a/activemq-unit-tests/src/test/resources/org/apache/activemq/network/remoteBroker-advancedStatistics.xml b/activemq-unit-tests/src/test/resources/org/apache/activemq/network/remoteBroker-advancedNetworkStatistics.xml
similarity index 85%
rename from activemq-unit-tests/src/test/resources/org/apache/activemq/network/remoteBroker-advancedStatistics.xml
rename to activemq-unit-tests/src/test/resources/org/apache/activemq/network/remoteBroker-advancedNetworkStatistics.xml
index 85953ce695..a9cf93f73a 100644
--- a/activemq-unit-tests/src/test/resources/org/apache/activemq/network/remoteBroker-advancedStatistics.xml
+++ b/activemq-unit-tests/src/test/resources/org/apache/activemq/network/remoteBroker-advancedNetworkStatistics.xml
@@ -28,11 +28,11 @@
     <destinationPolicy>
       <policyMap>
         <policyEntries>
-          <policyEntry queue="exclude.>" advancedStatisticsEnabled="true"/>
-          <policyEntry queue="include.>" advancedStatisticsEnabled="true"/> 
+          <policyEntry queue="exclude.>" advancedNetworkStatisticsEnabled="true"/>
+          <policyEntry queue="include.>" advancedNetworkStatisticsEnabled="true"/> 
           <policyEntry topic="ActiveMQ.Advisory.>" />
-          <policyEntry topic="exclude.>" advancedStatisticsEnabled="true"/>
-          <policyEntry topic="include.>" advancedStatisticsEnabled="true"/> 
+          <policyEntry topic="exclude.>" advancedNetworkStatisticsEnabled="true"/>
+          <policyEntry topic="include.>" advancedNetworkStatisticsEnabled="true"/> 
         </policyEntries>
       </policyMap>
     </destinationPolicy>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact