Class AbortSlowConsumerStrategy
java.lang.Object
org.apache.activemq.broker.region.policy.AbortSlowConsumerStrategy
- All Implemented Interfaces:
Runnable,SlowConsumerStrategy
- Direct Known Subclasses:
AbortSlowAckConsumerStrategy
Abort slow consumers when they reach the configured threshold of slowness, default is slow for 30 seconds
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Brokerprotected Stringprotected org.apache.activemq.thread.Schedulerprotected final Map<Subscription,SlowConsumerEntry> protected final AtomicBoolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabortConsumer(Subscription sub, boolean abortSubscriberConnection) protected voidabortSubscription(Map<Subscription, SlowConsumerEntry> toAbort, boolean abortSubscriberConnection) voidaddDestination(Destination destination) For Strategies that need to examine assigned destination for slow consumers periodically the destination is assigned here.longlonglonggetName()booleanbooleanReturns whether the strategy is configured to ignore subscriptions that are from a network connection.voidrun()voidsetAbortConnection(boolean abortConnection) abort the consumers connection rather than sending a stop command to the remote consumervoidsetBrokerService(Broker broker) Sets the Broker instance which can provide a Scheduler among other things.voidsetCheckPeriod(long checkPeriod) time in milliseconds between checks for slow subscriptionsvoidsetIgnoreNetworkConsumers(boolean ignoreNetworkConsumers) Sets whether the strategy is configured to ignore consumers that are part of a network connection to another broker.voidsetMaxSlowCount(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 dispatchvoidsetMaxSlowDuration(long maxSlowDuration) time in milliseconds that a sub can remain slow before triggering an abort.voidvoidslowConsumer(ConnectionContext context, Subscription subs) Slow consumer event.
-
Field Details
-
name
-
scheduler
protected org.apache.activemq.thread.Scheduler scheduler -
broker
-
taskStarted
-
slowConsumers
-
-
Constructor Details
-
AbortSlowConsumerStrategy
public AbortSlowConsumerStrategy()
-
-
Method Details
-
setBrokerService
Description copied from interface:SlowConsumerStrategySets the Broker instance which can provide a Scheduler among other things.- Specified by:
setBrokerServicein interfaceSlowConsumerStrategy- Parameters:
broker- The running Broker.
-
slowConsumer
Description copied from interface:SlowConsumerStrategySlow consumer event.- Specified by:
slowConsumerin interfaceSlowConsumerStrategy- Parameters:
context- Connection context of the subscription.subs- The subscription object for the slow consumer.
-
run
public void run() -
abortSubscription
protected void abortSubscription(Map<Subscription, SlowConsumerEntry> toAbort, boolean abortSubscriberConnection) -
abortConsumer
-
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
-
getName
-
getSlowConsumers
-
addDestination
Description copied from interface:SlowConsumerStrategyFor 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:
addDestinationin interfaceSlowConsumerStrategy- Parameters:
destination- A destination to add to a watch list.
-