activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject activemq git commit: AMQ-6947 - Update Queue metrics on expiration
Date Wed, 18 Apr 2018 13:06:37 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.15.x 1fe096cb2 -> bca0af413


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 6e468b4540754cad5cd30de373cadc026c998669)


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

Branch: refs/heads/activemq-5.15.x
Commit: bca0af4133a6e226783f8e953f1abe7d4e165743
Parents: 1fe096c
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Wed Apr 18 09:04:11 2018 -0400
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Wed Apr 18 09:06:31 2018 -0400

----------------------------------------------------------------------
 .../java/org/apache/activemq/broker/region/Queue.java  | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/bca0af41/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
----------------------------------------------------------------------
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 2946ac5..f669e41 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
@@ -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();
                             }


Mime
View raw message