activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject git commit: https://issues.apache.org/jira/browse/AMQ-4711 - totalMessageCount stat is not decremented after destination removal
Date Tue, 03 Sep 2013 08:22:59 GMT
Updated Branches:
  refs/heads/trunk 052577219 -> a0c1781c4


https://issues.apache.org/jira/browse/AMQ-4711 - totalMessageCount stat is not decremented
after destination removal


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/a0c1781c
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/a0c1781c
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/a0c1781c

Branch: refs/heads/trunk
Commit: a0c1781c4e909d35030d9762eaa70cf37639a569
Parents: 0525772
Author: Dejan Bosanac <dejan@nighttale.net>
Authored: Mon Sep 2 16:19:03 2013 +0200
Committer: Dejan Bosanac <dejan@nighttale.net>
Committed: Tue Sep 3 10:22:25 2013 +0200

----------------------------------------------------------------------
 .../activemq/management/CountStatisticImpl.java |  3 +++
 .../apache/activemq/broker/jmx/MBeanTest.java   | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/a0c1781c/activemq-client/src/main/java/org/apache/activemq/management/CountStatisticImpl.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/management/CountStatisticImpl.java
b/activemq-client/src/main/java/org/apache/activemq/management/CountStatisticImpl.java
index b88ba1c..bd5cd41 100755
--- a/activemq-client/src/main/java/org/apache/activemq/management/CountStatisticImpl.java
+++ b/activemq-client/src/main/java/org/apache/activemq/management/CountStatisticImpl.java
@@ -105,6 +105,9 @@ public class CountStatisticImpl extends StatisticImpl implements CountStatistic
     }
 
     public void setParent(CountStatisticImpl parent) {
+        if (this.parent != null) {
+            this.parent.subtract(this.getCount());
+        }
         this.parent = parent;
     }
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/a0c1781c/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
index 2e3ae2c..1327dd2 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
@@ -189,6 +189,26 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
 
     }
 
+    public void testRemoveQueue() throws Exception {
+        String queueName = "TEST";
+        ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
+        BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
brokerName, BrokerViewMBean.class, true);
+        broker.addQueue(queueName);
+
+        ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName="
+ queueName);
+
+        QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
queueViewMBeanName, QueueViewMBean.class, true);
+        queue.sendTextMessage("message 1");
+        queue.sendTextMessage("message 2");
+
+        assertEquals(2, broker.getTotalMessageCount());
+
+        broker.removeQueue(queueName);
+
+        assertEquals(0, broker.getTotalMessageCount());
+
+    }
+
     public void testRetryMessages() throws Exception {
         // lets speed up redelivery
         ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) connectionFactory;


Mime
View raw message