Class AbortSlowAckConsumerStrategy

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

public class AbortSlowAckConsumerStrategy extends AbortSlowConsumerStrategy
Abort slow consumers when they reach the configured threshold of slowness, default is that a consumer that has not Ack'd a message for 30 seconds is slow.
  • Constructor Details

    • AbortSlowAckConsumerStrategy

      public AbortSlowAckConsumerStrategy()
  • 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
      Overrides:
      setBrokerService in class AbortSlowConsumerStrategy
      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
      Overrides:
      slowConsumer in class AbortSlowConsumerStrategy
      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
      Overrides:
      run in class AbortSlowConsumerStrategy
    • 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
      Overrides:
      addDestination in class AbortSlowConsumerStrategy
      Parameters:
      destination - A destination to add to a watch list.
    • getMaxTimeSinceLastAck

      public long getMaxTimeSinceLastAck()
      Gets the maximum time since last Ack before a subscription is considered to be slow.
      Returns:
      the maximum time since last Ack before the consumer is considered to be slow.
    • setMaxTimeSinceLastAck

      public void setMaxTimeSinceLastAck(long maxTimeSinceLastAck)
      Sets the maximum time since last Ack before a subscription is considered to be slow.
      Parameters:
      maxTimeSinceLastAck - the maximum time since last Ack (mills) before the consumer is considered to be slow.
    • isIgnoreIdleConsumers

      public boolean isIgnoreIdleConsumers()
      Returns whether the strategy is configured to ignore consumers that are simply idle, i.e consumers that have no pending acks (dispatch queue is empty).
      Returns:
      true if the strategy will ignore idle consumer when looking for slow consumers.
    • setIgnoreIdleConsumers

      public void setIgnoreIdleConsumers(boolean ignoreIdleConsumers)
      Sets whether the strategy is configured to ignore consumers that are simply idle, i.e consumers that have no pending acks (dispatch queue is empty). When configured to not ignore idle consumers this strategy acks 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.
      Parameters:
      ignoreIdleConsumers - Should this strategy ignore idle consumers or consider all consumers when checking the last ack time verses the maxTimeSinceLastAck value.