Class MessageEvictionStrategySupport

java.lang.Object
org.apache.activemq.broker.region.policy.MessageEvictionStrategySupport
All Implemented Interfaces:
MessageEvictionStrategy
Direct Known Subclasses:
OldestMessageEvictionStrategy, OldestMessageWithLowestPriorityEvictionStrategy, UniquePropertyMessageEvictionStrategy

public abstract class MessageEvictionStrategySupport extends Object implements MessageEvictionStrategy
A useful base class for implementation inheritence.
  • Constructor Details

    • MessageEvictionStrategySupport

      public MessageEvictionStrategySupport()
  • Method Details

    • getEvictExpiredMessagesHighWatermark

      public int getEvictExpiredMessagesHighWatermark()
      Description copied from interface: MessageEvictionStrategy
      REturns the high water mark on which we will eagerly evict expired messages from RAM
      Specified by:
      getEvictExpiredMessagesHighWatermark in interface MessageEvictionStrategy
    • setEvictExpiredMessagesHighWatermark

      public void setEvictExpiredMessagesHighWatermark(int evictExpiredMessagesHighWaterMark)
      Sets the high water mark on which we will eagerly evict expired messages from RAM
    • isExpiryCheckEnabled

      public boolean isExpiryCheckEnabled()
      Description copied from interface: MessageEvictionStrategy
      Returns whether the eager expired-message scan is enabled.

      When false, the O(n) scan inside TopicSubscription.add(MessageReference) is skipped entirely. Set to false when messages carry no TTL, or when the scan cost outweighs the benefit of eagerly evicting expired messages from slow-consumer buffers.

      See MessageEvictionStrategySupport for the default implementation that returns true.

      Specified by:
      isExpiryCheckEnabled in interface MessageEvictionStrategy
      Returns:
      true if the expiry scan is enabled (default), false if skipped
    • setExpiryCheckEnabled

      public void setExpiryCheckEnabled(boolean expiryCheckEnabled)
      Controls whether the broker performs an eager expired-message scan when a non-durable topic subscription's pending slow-consumer buffer exceeds getEvictExpiredMessagesHighWatermark().

      Set to false when messages carry no TTL, or when the O(n) scan cost outweighs the benefit of eagerly evicting expired messages from slow-consumer buffers. When messages have no TTL, every scan iterates the full buffer without removing anything, adding latency to every enqueue once the buffer exceeds the high-water mark.

      Parameters:
      expiryCheckEnabled - false to skip the scan; true to enable it (default)