Class AbortSlowConsumerStrategy

java.lang.Object
org.apache.activemq.broker.region.policy.AbortSlowConsumerStrategy
All Implemented Interfaces:
Runnable, SlowConsumerStrategy
Direct Known Subclasses:
AbortSlowAckConsumerStrategy

public class AbortSlowConsumerStrategy extends Object implements SlowConsumerStrategy, Runnable
Abort slow consumers when they reach the configured threshold of slowness, default is slow for 30 seconds
  • Field Details

  • Constructor Details

    • AbortSlowConsumerStrategy

      public AbortSlowConsumerStrategy()
  • Method Details

    • setBrokerService

      public void setBrokerService(Broker broker)
      Description copied from interface: SlowConsumerStrategy
      Sets the Broker instance which can provide a Scheduler among other things.
      Specified by:
      setBrokerService in interface SlowConsumerStrategy
      Parameters:
      broker - The running Broker.
    • slowConsumer

      public void slowConsumer(ConnectionContext context, Subscription subs)
      Description copied from interface: SlowConsumerStrategy
      Slow consumer event.
      Specified by:
      slowConsumer in interface SlowConsumerStrategy
      Parameters:
      context - Connection context of the subscription.
      subs - The subscription object for the slow consumer.
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • abortSubscription

      protected void abortSubscription(Map<Subscription,SlowConsumerEntry> toAbort, boolean abortSubscriberConnection)
    • abortConsumer

      public void abortConsumer(Subscription sub, boolean abortSubscriberConnection)
    • getMaxSlowCount

      public long getMaxSlowCount()
    • setMaxSlowCount

      public void setMaxSlowCount(long maxSlowCount)
      number of times a subscription can be deemed slow before triggering abort effect depends on dispatch rate as slow determination is done on dispatch
    • getMaxSlowDuration

      public long getMaxSlowDuration()
    • setMaxSlowDuration

      public void setMaxSlowDuration(long maxSlowDuration)
      time in milliseconds that a sub can remain slow before triggering an abort.
      Parameters:
      maxSlowDuration -
    • getCheckPeriod

      public long getCheckPeriod()
    • setCheckPeriod

      public void setCheckPeriod(long checkPeriod)
      time in milliseconds between checks for slow subscriptions
      Parameters:
      checkPeriod -
    • isAbortConnection

      public boolean isAbortConnection()
    • setAbortConnection

      public void setAbortConnection(boolean abortConnection)
      abort the consumers connection rather than sending a stop command to the remote consumer
      Parameters:
      abortConnection -
    • isIgnoreNetworkSubscriptions

      public boolean isIgnoreNetworkSubscriptions()
      Returns whether the strategy is configured to ignore subscriptions that are from a network connection.
      Returns:
      true if the strategy will ignore network connection subscriptions when looking for slow consumers.
    • setIgnoreNetworkConsumers

      public void setIgnoreNetworkConsumers(boolean ignoreNetworkConsumers)
      Sets whether the strategy is configured to ignore consumers that are part of a network connection to another broker. When configured to not ignore idle consumers this strategy acts not only on consumers that are actually slow but also on any consumer that has not received any messages for the maxTimeSinceLastAck. This allows for a way to evict idle consumers while also aborting slow consumers however for a network subscription this can create a lot of unnecessary churn and if the abort connection option is also enabled this can result in the entire network connection being torn down and rebuilt for no reason.
      Parameters:
      ignoreNetworkConsumers - Should this strategy ignore subscriptions made by a network connector.
    • setName

      public void setName(String name)
    • getName

      public String getName()
    • getSlowConsumers

      public Map<Subscription,SlowConsumerEntry> getSlowConsumers()
    • addDestination

      public void addDestination(Destination destination)
      Description copied from interface: SlowConsumerStrategy
      For Strategies that need to examine assigned destination for slow consumers periodically the destination is assigned here. If the strategy doesn't is event driven it can just ignore assigned destination.
      Specified by:
      addDestination in interface SlowConsumerStrategy
      Parameters:
      destination - A destination to add to a watch list.