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

This commit is contained in:
Dejan Bosanac 2013-09-02 16:19:03 +02:00
parent 0525772190
commit a0c1781c4e
2 changed files with 23 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;