This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit 246bf083914c7acbb05a7fe0904c471331242c39
Author: Justin Bertram <[email protected]>
AuthorDate: Mon Sep 21 10:10:22 2020 -0500

    ARTEMIS-2909 revert ARTEMIS-2322
    
    This reverts commit dbb3a90fe6d2718fef0b8ae75123519b1404ef1f.
    
    The org.apache.activemq.artemis.core.server.Queue#getRate method is for
    slow-consumer detection and is designed for internal use only.
    
    Furthermore, it's too opaque to be trusted by a remote user as it only
    returns the number of message added to the queue since *the last time
    it was called*. The problem here is that the user calling it doesn't
    know when it was invoked last. Therefore, they could be getting the
    rate of messages added for the last 5 minutes or the last 5
    milliseconds. This can lead to inconsistent and misleading results.
    
    There are three main ways for users to track rates of message
    production and consumption:
    
     1. Use a metrics plugin. This is the most feature-rich and flexible
    way to track broker metrics, although it requires tools (e.g.
    Prometheus) to store the metrics and display them (e.g. Grafana).
    
     2. Invoke the getMessageCount() and getMessagesAdded() management
    methods and store the returned values along with the time they were
    retrieved. A time-series database is a great tool for this job. This is
    exactly what tools like Prometheus do. That data can then be used to
    create informative graphs, etc. using tools like Grafana. Of course, one
    can skip all the tools and just do some simple math to calculate rates
    based on the last time the counts were retrieved.
    
     3. Use the broker's message counters. Message counters are the broker's
    simple way of providing historical information about the queue. They
    provide similar results to the previous solutions, but with less
    flexibility since they only track data while the broker is up and
    there's not really any good options for graphing.
---
 .../apache/activemq/artemis/logs/AuditLogger.java  |  8 --------
 .../artemis/api/core/management/QueueControl.java  |  6 ------
 .../core/management/impl/QueueControlImpl.java     | 23 ++++++----------------
 .../management/QueueControlUsingCoreTest.java      |  5 -----
 4 files changed, 6 insertions(+), 36 deletions(-)

diff --git 
a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AuditLogger.java
 
b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AuditLogger.java
index 2add0c3..7fd9387 100644
--- 
a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AuditLogger.java
+++ 
b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AuditLogger.java
@@ -2299,14 +2299,6 @@ public interface AuditLogger extends BasicLogger {
    @Message(id = 601267, value = "User {0} is creating a core session on 
target resource {1} {2}", format = Message.Format.MESSAGE_FORMAT)
    void createCoreSession(String user, Object source, Object... args);
 
-   static void getProducedRate(Object source) {
-      LOGGER.getProducedRate(getCaller(), source);
-   }
-
-   @LogMessage(level = Logger.Level.INFO)
-   @Message(id = 601268, value = "User {0} is getting produced message rate on 
target resource: {1} {2}", format = Message.Format.MESSAGE_FORMAT)
-   void getProducedRate(String user, Object source, Object... args);
-
    static void getAcknowledgeAttempts(Object source) {
       LOGGER.getMessagesAcknowledged(getCaller(), source);
    }
diff --git 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
index f767905..4b09a5f 100644
--- 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
+++ 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
@@ -106,12 +106,6 @@ public interface QueueControl {
    long getMessageCount();
 
    /**
-    * Returns the rate of writing messages to the queue.
-    */
-   @Attribute(desc = "rate of writing messages to the queue currently (based 
on default window function)")
-   float getProducedRate();
-
-   /**
     * Returns the persistent size of all messages currently in this queue. The 
persistent size of a message
     * is the amount of space the message would take up on disk which is used 
to track how much data there
     * is to consume on this queue
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
index 85cb672..cdf589d 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
@@ -271,17 +271,6 @@ public class QueueControlImpl extends AbstractControl 
implements QueueControl {
    }
 
    @Override
-   public float getProducedRate() {
-      if (AuditLogger.isEnabled()) {
-         AuditLogger.getProducedRate(queue);
-      }
-      checkStarted();
-
-      // This is an attribute, no need to blockOnIO
-      return queue.getRate();
-   }
-
-   @Override
    public long getPersistentSize() {
       if (AuditLogger.isEnabled()) {
          AuditLogger.getPersistentSize(queue);
@@ -920,7 +909,7 @@ public class QueueControlImpl extends AbstractControl 
implements QueueControl {
          AuditLogger.countMessages(queue, filterStr);
       }
 
-      Long value = internalCountMessages(filterStr, null).get(null);
+      Long value = intenalCountMessages(filterStr, null).get(null);
       return value == null ? 0 : value;
    }
 
@@ -930,10 +919,10 @@ public class QueueControlImpl extends AbstractControl 
implements QueueControl {
          AuditLogger.countMessages(queue, filterStr, groupByProperty);
       }
 
-      return JsonUtil.toJsonObject(internalCountMessages(filterStr, 
groupByProperty)).toString();
+      return JsonUtil.toJsonObject(intenalCountMessages(filterStr, 
groupByProperty)).toString();
    }
 
-   private Map<String, Long> internalCountMessages(final String filterStr, 
final String groupByPropertyStr) throws Exception {
+   private Map<String, Long> intenalCountMessages(final String filterStr, 
final String groupByPropertyStr) throws Exception {
       checkStarted();
 
       clearIO();
@@ -968,7 +957,7 @@ public class QueueControlImpl extends AbstractControl 
implements QueueControl {
          AuditLogger.countDeliveringMessages(queue, filterStr);
       }
 
-      Long value = internalCountDeliveryMessages(filterStr, null).get(null);
+      Long value = intenalCountDeliveryMessages(filterStr, null).get(null);
       return value == null ? 0 : value;
    }
 
@@ -978,10 +967,10 @@ public class QueueControlImpl extends AbstractControl 
implements QueueControl {
          AuditLogger.countDeliveringMessages(queue, filterStr, 
groupByProperty);
       }
 
-      return JsonUtil.toJsonObject(internalCountDeliveryMessages(filterStr, 
groupByProperty)).toString();
+      return JsonUtil.toJsonObject(intenalCountDeliveryMessages(filterStr, 
groupByProperty)).toString();
    }
 
-   private Map<String, Long> internalCountDeliveryMessages(final String 
filterStr, final String groupByPropertyStr) throws Exception {
+   private Map<String, Long> intenalCountDeliveryMessages(final String 
filterStr, final String groupByPropertyStr) throws Exception {
       checkStarted();
 
       clearIO();
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
index 85ed6e3..f091df6 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
@@ -260,11 +260,6 @@ public class QueueControlUsingCoreTest extends 
QueueControlTest {
          }
 
          @Override
-         public float getProducedRate() {
-            return (Long) proxy.retrieveAttributeValue("producedRate", 
Long.class);
-         }
-
-         @Override
          public long getMessagesAdded() {
             return (Integer) proxy.retrieveAttributeValue("messagesAdded", 
Integer.class);
          }

Reply via email to