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.
-
-
Field Summary
-
Fields inherited from class org.apache.activemq.broker.region.policy.AbortSlowConsumerStrategy
broker, name, scheduler, slowConsumers, taskStarted
-
-
Constructor Summary
Constructors Constructor Description AbortSlowAckConsumerStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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).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
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, isIgnoreNetworkSubscriptions, setAbortConnection, setCheckPeriod, setIgnoreNetworkConsumers, setMaxSlowCount, setMaxSlowDuration, setName
-
-
-
-
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 interfaceSlowConsumerStrategy
- Overrides:
setBrokerService
in classAbortSlowConsumerStrategy
- 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 interfaceSlowConsumerStrategy
- Overrides:
slowConsumer
in classAbortSlowConsumerStrategy
- Parameters:
context
- Connection context of the subscription.subs
- The subscription object for the slow consumer.
-
run
public void run()
- Specified by:
run
in interfaceRunnable
- Overrides:
run
in classAbortSlowConsumerStrategy
-
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 interfaceSlowConsumerStrategy
- Overrides:
addDestination
in classAbortSlowConsumerStrategy
- 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.
-
-