org.apache.activemq.broker.region.policy
Class AbortSlowAckConsumerStrategy

java.lang.Object
  extended by org.apache.activemq.broker.region.policy.AbortSlowConsumerStrategy
      extended by 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.


Field Summary
 
Fields inherited from class org.apache.activemq.broker.region.policy.AbortSlowConsumerStrategy
broker, name, scheduler, slowConsumers, taskStarted
 
Constructor Summary
AbortSlowAckConsumerStrategy()
           
 
Method Summary
 void addDestination(Destination destination)
          For Strategies that need to examine assigned destination for slow consumers periodically the destination is assigned here.
 long getMaxTimeSinceLastAck()
          Gets the maximum time since last Ack before a subscription is considered to be slow.
 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).
 boolean isIgnoreNetworkSubscriptions()
          Returns whether the strategy is configured to ignore subscriptions that are from a network connection.
 void run()
           
 void setBrokerService(Broker broker)
          Sets the Broker instance which can provide a Scheduler among other things.
 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).
 void setIgnoreNetworkConsumers(boolean ignoreNetworkConsumers)
          Sets whether the strategy is configured to ignore consumers that are part of a network connection to another broker.
 void setMaxTimeSinceLastAck(long maxTimeSinceLastAck)
          Sets the maximum time since last Ack before a subscription is considered to be slow.
 void slowConsumer(ConnectionContext context, Subscription subs)
          Slow consumer event.
 
Methods inherited from class org.apache.activemq.broker.region.policy.AbortSlowConsumerStrategy
abortConsumer, abortSubscription, getCheckPeriod, getMaxSlowCount, getMaxSlowDuration, getName, getSlowConsumers, isAbortConnection, setAbortConnection, setCheckPeriod, setMaxSlowCount, setMaxSlowDuration, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbortSlowAckConsumerStrategy

public AbortSlowAckConsumerStrategy()
Method Detail

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.

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.


Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.