Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-6579

Expired messages counting as Dispatched on TopicSubscription

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.15.0, 5.14.3
    • 5.15.0, 5.14.4
    • None
    • None

    Description

      When a TopicSubscription is configured with a limit on the number of pending messages, it will try to eagerly evict expired messages before dispatching them.

      TopicSubscription.java:169
      if (!matched.isEmpty() && matched.size() > max) {
        removeExpiredMessages();
      }
      

      When TopicSubscription#removeExpiredMessages detects an expired message, it will remove it but will increment the counter of dispatched messages as well.

      TopicSubscription.java:235
      if (node.isExpired()) {
        matched.remove();
        getSubscriptionStatistics().getDispatched().increment();
        node.decrementReferenceCount();
        if (broker.isExpired(node)) {
          ((Destination) node.getRegionDestination()).getDestinationStatistics().getExpired().increment();
          broker.messageExpired(getContext(), node, this);
        }
        break;
      }
      

      However this has the side effect of affecting the result of getDispatchedQueueSize() and therefore isFull(). These counters will now reflect a new dispatched message that has actually been dropped.

      In the worst case scenario slow consumers will no longer receive messages because they are "full" when in fact they have nothing to process.

      Am I correct in concluding that expired messages must not count towards the dispatched value?

      I have made a quick change, removing the increment, and things look good so far. However I am worried that I may be missing some side effect or specification detail.

      Attachments

        Activity

          People

            cshannon Christopher L. Shannon
            vveloso Vasco Veloso
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: