Class AMQPFederationConsumerManager<E, Consumer extends AMQPFederationConsumer>
java.lang.Object
org.apache.activemq.artemis.protocol.amqp.connect.federation.AMQPFederationConsumerManager<E,Consumer>
- Type Parameters:
E- The type used in the demand tracking collection.
public abstract class AMQPFederationConsumerManager<E, Consumer extends AMQPFederationConsumer>
extends Object
An abstract base for managing federation consumer instances that holds the demand currently present for a federated
resource and the consumer that exists to service that demand. This object manages the state of the consumer and the
various stages it can pass through during its lifetime.
All interactions with the consumer tracking entry should occur under the lock of the parent manager instance and this manager will perform any asynchronous work with a lock held on the parent manager instance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AMQPFederationprotected final AMQPFederationLocalPolicyManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd new demand to the consumer manager which creates or sustains the consumer lifetime that this manager maintains.protected abstract ConsumercreateFederationConsumer(Set<E> currentDemand) Creates a new federation consumer that this manager will monitor and maintain.protected abstract booleanQuery all registered plugins for this federation instance to determine if any wish to prevent a federation consumer from being created for the given resource managed by the implementation class.voidrecover()Attempt to recover a stopped consumer if this manager is not in the closed state and there is active demand registered.voidremoveDemand(E demand) Remove the given element from the tracked consumer demand.voidshutdown()An orderly shutdown of the federation consumer which will perform a drain of link credit before closing the consumer to ensure that all in-flight messages and dispositions are processed before the link is detached.voidAn immediate close of the federation consumer which does not drain link credit or wait for any pending operations to complete.protected abstract voidwhenDemandTrackingEntryAdded(E entry, Consumer consumer) An event point that a subclass can use to perform an initialization action whenever an entry is added to demand tracking.protected abstract voidwhenDemandTrackingEntryRemoved(E entry, Consumer consumer) An event point that a subclass can use to perform a cleanup action whenever an entry is removed from demand tracking.
-
Field Details
-
federation
-
manager
-
-
Constructor Details
-
AMQPFederationConsumerManager
-
-
Method Details
-
shutdown
public void shutdown()An orderly shutdown of the federation consumer which will perform a drain of link credit before closing the consumer to ensure that all in-flight messages and dispositions are processed before the link is detached.The federation manager should be calling this method with its lock held.
-
shutdownNow
public void shutdownNow()An immediate close of the federation consumer which does not drain link credit or wait for any pending operations to complete.The federation manager should be calling this method with its lock held.
-
recover
public void recover()Attempt to recover a stopped consumer if this manager is not in the closed state and there is active demand registered. When in the stopped state the existing consumer will be restarted and if no active consumer exists then a new consumer is created. If this is called while a consumer is in the started state then this operation is a no-op and the consumer is left as is.The federation manager should be calling this method with its lock held.
-
addDemand
Add new demand to the consumer manager which creates or sustains the consumer lifetime that this manager maintains. When the first element of demand is added a new consumer is attached and when the last unit of demand is removed the consumer will be closed.The federation manager should be calling this method with its lock held.
- Parameters:
demand- A new unit of demand to add to this consumer manager.
-
removeDemand
Remove the given element from the tracked consumer demand. If the tracked demand reaches zero then the managed consumer should be closed and the manager awaits future demand to be added. The manager can opt to hold a stopped consumer open for some period of time to avoid spurious open and closes as demand is added and removed.The federation manager should be calling this method with its lock held.
- Parameters:
demand- The element of demand that should be removed from tracking.
-
whenDemandTrackingEntryAdded
An event point that a subclass can use to perform an initialization action whenever an entry is added to demand tracking.- Parameters:
entry- The entry that is being added to demand tracking.consumer- The currently active federation consumer (can be null if no consumer).
-
whenDemandTrackingEntryRemoved
An event point that a subclass can use to perform a cleanup action whenever an entry is removed from demand tracking.- Parameters:
entry- The entry that is being removed from demand tracking.consumer- The currently active federation consumer (can be null if no consumer).
-
createFederationConsumer
Creates a new federation consumer that this manager will monitor and maintain. The returned consumer should be in an initial state ready for this manager to initialize once it is fully configured.- Parameters:
currentDemand- UnmodifiableSetof entries that account for the demand on the consumer being created.- Returns:
- a newly create
AMQPFederationConsumerfor use by this manager
-
isPluginBlockingFederationConsumerCreate
protected abstract boolean isPluginBlockingFederationConsumerCreate()Query all registered plugins for this federation instance to determine if any wish to prevent a federation consumer from being created for the given resource managed by the implementation class.- Returns:
trueif any registered plugin signaled that creation should be suppressed
-