mirror of https://github.com/apache/activemq.git
AMQ-6947 - Update Queue metrics on expiration
The updated dropMessage method only decrements the destination metrics
if a message is removed from the pagedInMessages list to prevent
duplicate updates. There is also a case where we still need to update
metrics if the message never makes it into the pagedInMessages list in
the first place and that is on expiration so this patch fixes that. A
couple existing tests found this issue.
(cherry picked from commit 6e468b4540
)
This commit is contained in:
parent
1fe096cb2a
commit
bca0af4133
|
@ -1842,8 +1842,7 @@ public class Queue extends BaseDestination implements Task, UsageListener, Index
|
|||
pagedInMessagesLock.writeLock().lock();
|
||||
try {
|
||||
if (pagedInMessages.remove(reference) != null) {
|
||||
getDestinationStatistics().getDequeues().increment();
|
||||
getDestinationStatistics().getMessages().decrement();
|
||||
updateMetricsOnMessageDrop();
|
||||
}
|
||||
} finally {
|
||||
pagedInMessagesLock.writeLock().unlock();
|
||||
|
@ -1851,6 +1850,11 @@ public class Queue extends BaseDestination implements Task, UsageListener, Index
|
|||
}
|
||||
}
|
||||
|
||||
private void updateMetricsOnMessageDrop() {
|
||||
getDestinationStatistics().getDequeues().increment();
|
||||
getDestinationStatistics().getMessages().decrement();
|
||||
}
|
||||
|
||||
public void messageExpired(ConnectionContext context, MessageReference reference) {
|
||||
messageExpired(context, null, reference);
|
||||
}
|
||||
|
@ -2007,6 +2011,11 @@ public class Queue extends BaseDestination implements Task, UsageListener, Index
|
|||
if (processExpired && ref.isExpired()) {
|
||||
if (broker.isExpired(ref)) {
|
||||
messageExpired(createConnectionContext(), ref);
|
||||
|
||||
//We need to update the metrics here because the drop message
|
||||
//method will only update if the message was removed from the
|
||||
//pagedInMessages list which won't happen in this case
|
||||
updateMetricsOnMessageDrop();
|
||||
} else {
|
||||
ref.decrementReferenceCount();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue