mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-4598 - negative queue size after purge
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1496430 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
06dae40d94
commit
e3fb8be2ba
|
@ -563,6 +563,7 @@ public class Queue extends BaseDestination implements Task, UsageListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (MessageReference ref : unAckedMessages) {
|
||||
QueueMessageReference qmr = (QueueMessageReference) ref;
|
||||
if (qmr.getLockOwner() == sub) {
|
||||
|
@ -581,7 +582,9 @@ public class Queue extends BaseDestination implements Task, UsageListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
redeliveredWaitingDispatch.addMessageLast(qmr);
|
||||
if (!qmr.isDropped()) {
|
||||
redeliveredWaitingDispatch.addMessageLast(qmr);
|
||||
}
|
||||
}
|
||||
if (sub instanceof QueueBrowserSubscription) {
|
||||
((QueueBrowserSubscription)sub).decrementQueueRef();
|
||||
|
@ -1800,13 +1803,15 @@ public class Queue extends BaseDestination implements Task, UsageListener {
|
|||
}
|
||||
|
||||
private void dropMessage(QueueMessageReference reference) {
|
||||
reference.drop();
|
||||
destinationStatistics.getMessages().decrement();
|
||||
pagedInMessagesLock.writeLock().lock();
|
||||
try{
|
||||
pagedInMessages.remove(reference.getMessageId());
|
||||
}finally {
|
||||
pagedInMessagesLock.writeLock().unlock();
|
||||
if (!reference.isDropped()) {
|
||||
reference.drop();
|
||||
destinationStatistics.getMessages().decrement();
|
||||
pagedInMessagesLock.writeLock().lock();
|
||||
try {
|
||||
pagedInMessages.remove(reference.getMessageId());
|
||||
} finally {
|
||||
pagedInMessagesLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,6 +134,14 @@ public class QueuePurgeTest extends CombinationTestSupport {
|
|||
assertEquals("Queue size is not zero, it's " + proxy.getQueueSize(), 0,
|
||||
proxy.getQueueSize());
|
||||
assertEquals("usage goes to duck", 0, proxy.getMemoryPercentUsage());
|
||||
Message msg;
|
||||
do {
|
||||
msg = consumer.receive(1000);
|
||||
if (msg != null) {
|
||||
msg.acknowledge();
|
||||
}
|
||||
} while (msg != null);
|
||||
assertEquals("Queue size not valid", 0, proxy.getQueueSize());
|
||||
}
|
||||
|
||||
private QueueViewMBean getProxyToQueueViewMBean()
|
||||
|
|
Loading…
Reference in New Issue