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

    Fields
    Modifier and Type
    Field
    Description
    protected final AMQPFederation
     
     
  • Constructor Summary

    Constructors
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDemand(E demand)
    Add new demand to the consumer manager which creates or sustains the consumer lifetime that this manager maintains.
    protected abstract Consumer
    createFederationConsumer(Set<E> currentDemand)
    Creates a new federation consumer that this manager will monitor and maintain.
    protected abstract boolean
    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.
    void
    Attempt to recover a stopped consumer if this manager is not in the closed state and there is active demand registered.
    void
    removeDemand(E demand)
    Remove the given element from the tracked consumer demand.
    void
    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.
    void
    An immediate close of the federation consumer which does not drain link credit or wait for any pending operations to complete.
    protected abstract void
    An event point that a subclass can use to perform an initialization action whenever an entry is added to demand tracking.
    protected abstract void
    An event point that a subclass can use to perform a cleanup action whenever an entry is removed from demand tracking.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • 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

      public void addDemand(E demand)
      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

      public void removeDemand(E demand)
      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

      protected abstract void whenDemandTrackingEntryAdded(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.
      Parameters:
      entry - The entry that is being added to demand tracking.
      consumer - The currently active federation consumer (can be null if no consumer).
    • whenDemandTrackingEntryRemoved

      protected abstract void whenDemandTrackingEntryRemoved(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.
      Parameters:
      entry - The entry that is being removed from demand tracking.
      consumer - The currently active federation consumer (can be null if no consumer).
    • createFederationConsumer

      protected abstract Consumer createFederationConsumer(Set<E> currentDemand)
      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 - Unmodifiable Set of entries that account for the demand on the consumer being created.
      Returns:
      a newly create AMQPFederationConsumer for 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:
      true if any registered plugin signaled that creation should be suppressed