Uploaded image for project: 'ActiveMQ Artemis'
  1. ActiveMQ Artemis
  2. ARTEMIS-1011

Slow consumer detection - producer msg/s rate for queue should take into account messages which are already in queue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.3
    • 2.10.0
    • Broker
    • None

    Description

      There is still a problem how producer msg/s rate is calculated in QueueImpl.getRate() for slow consumer detection. It calculates only messages added during the last slow consumer check period. As this is used to figure out, in which msg/s rate the queue could serve the consumer then it should also take into account messages which are already in queue at the start of queueRateCheckTime period.

      Current implementation is problem for cases when messages are sent to queue in bursts, for example producer sends 1000s messages in a few seconds and then stops and will do that again in 1 hour. QueueImpl.getRate() method returns 0 msg/s for slow consumer check period set to for example 5 min and slow consumer detection will be skipped.

      I tried to fix it by following change to QueueImpl.getRate() method and seems to be ok, wdyt?

         private final AtomicLong messageCountSnapshot = new AtomicLong(0);
         public float getRate() {
            long locaMessageAdded = getMessagesAdded();
            float timeSlice = ((System.currentTimeMillis() - queueRateCheckTime.getAndSet(System.currentTimeMillis())) / 1000.0f);
            if (timeSlice == 0) {
               messagesAddedSnapshot.getAndSet(locaMessageAdded);
               return 0.0f;
            }
            return BigDecimal.valueOf(((locaMessageAdded - messagesAddedSnapshot.getAndSet(locaMessageAdded)) + messageCountSnapshot.getAndSet(getMessageCount())) / timeSlice).setScale(2, BigDecimal.ROUND_UP).floatValue();
         }
      

      Attachments

        Issue Links

          Activity

            People

              jbertram Justin Bertram
              mnovak Miroslav Novak
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m