Class MessageCounter

java.lang.Object
org.apache.activemq.artemis.core.messagecounter.MessageCounter

public class MessageCounter extends Object
This class stores message count informations for a given queue

At intervals this class samples the queue for message count data

Note that the underlying queue *does not* update statistics every time a message is added since that would reall slow things down, instead we *sample* the queues at regular intervals - this means we are less intrusive on the queue

  • Constructor Details

    • MessageCounter

      public MessageCounter(String name, String subscription, Queue serverQueue, boolean topic, boolean durable, int daycountmax)
      Constructor
      Parameters:
      name - destination name
      subscription - subscription name
      serverQueue - internal queue object
      topic - topic destination flag
      durable - durable subscription flag
      daycountmax - max message history day count
  • Method Details

    • onTimer

      public void onTimer()
      This method is called periodically to update statistics from the queue
    • getDestinationName

      public String getDestinationName()
    • getDestinationSubscription

      public String getDestinationSubscription()
    • isDestinationTopic

      public boolean isDestinationTopic()
    • isDestinationDurable

      public boolean isDestinationDurable()
    • getCount

      public long getCount()
      Gets the total message count since startup or last counter reset
    • getCountDelta

      public long getCountDelta()
      Gets the message count delta since last method call
    • getMessageCount

      public long getMessageCount()
      Gets the current message count of pending messages within the destination waiting for dispatch
    • getMessageCountDelta

      public long getMessageCountDelta()
      Gets the message count delta of pending messages since last method call.
    • getLastUpdate

      public long getLastUpdate()
    • getLastAddedMessageTime

      public long getLastAddedMessageTime()
    • getLastAckedMessageTime

      public long getLastAckedMessageTime()
    • resetCounter

      public void resetCounter()
    • resetHistory

      public void resetHistory()
    • getHistory

      public List<MessageCounter.DayCounter> getHistory()
    • getHistoryAsString

      public String getHistoryAsString()
      Get message counter history data as string in format
       day count
       Date 1, hour counter 0, hour counter 1, ..., hour counter 23
       Date 2, hour counter 0, hour counter 1, ..., hour counter 23
       .....
       .....
       Date n, hour counter 0, hour counter 1, ..., hour counter 23
       
      Returns:
      String message history data string
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toJSon

      public String toJSon()
      Returns a JSON String serialization of a MessageCounter object.
      Returns:
      a JSON String serialization of a MessageCounter object