Class FederationQueuePolicyManager

    • Method Detail

      • start

        public void start()
        Start the queue policy manager which will initiate a scan of all broker queue bindings and create and matching remote receivers. Start on a policy manager should only be called after its parent Federation is started and the federation connection has been established.
      • stop

        public void stop()
        Stops the queue policy manager which will close any open remote receivers that are active for local queue demand. Stop should generally be called whenever the parent Federation loses its connection to the remote.
      • scanAllQueueBindings

        protected final void scanAllQueueBindings()
      • checkQueueForMatch

        protected final void checkQueueForMatch​(org.apache.activemq.artemis.core.server.Queue queue)
      • reactIfConsumerMatchesPolicy

        protected final void reactIfConsumerMatchesPolicy​(org.apache.activemq.artemis.core.server.ServerConsumer consumer)
      • afterRemoteQueueAdded

        public void afterRemoteQueueAdded​(String addressName,
                                          String queueName)
                                   throws Exception
        Checks if the remote queue added falls within the set of queues that match the configured queue policy and if so scans for local demand on that queue to see if a new attempt to federate the queue is needed.
        Parameters:
        addressName - The address that was added on the remote.
        queueName - The queue that was added on the remote.
        Throws:
        Exception - if an error occurs while processing the queue added event.
      • testIfQueueMatchesPolicy

        protected boolean testIfQueueMatchesPolicy​(String address,
                                                   String queueName)
        Performs the test against the configured queue policy to check if the target queue and its associated address is a match or not. A subclass can override this method and provide its own match tests in combination with the configured matching policy.
        Parameters:
        address - The address that is being tested for a policy match.
        queueName - The name of the queue that is being tested for a policy match.
        Returns:
        true if the address given is a match against the policy.
      • testIfQueueMatchesPolicy

        protected boolean testIfQueueMatchesPolicy​(String queueName)
        Performs the test against the configured queue policy to check if the target queue minus its associated address is a match or not. A subclass can override this method and provide its own match tests in combination with the configured matching policy.
        Parameters:
        queueName - The name of the queue that is being tested for a policy match.
        Returns:
        true if the address given is a match against the policy.
      • handlePolicyManagerStarted

        protected abstract void handlePolicyManagerStarted​(FederationReceiveFromQueuePolicy policy)
        Called on start of the manager before any other actions are taken to allow the subclass time to configure itself and prepare any needed state prior to starting management of federated resources.
        Parameters:
        policy - The policy configuration for this policy manager.
      • createConsumerInfo

        protected abstract FederationConsumerInfo createConsumerInfo​(org.apache.activemq.artemis.core.server.ServerConsumer consumer)
        Create a new FederationConsumerInfo based on the given ServerConsumer and the configured FederationReceiveFromQueuePolicy. A subclass must override this method to return a consumer information object with additional data used be that implementation.
        Parameters:
        consumer - The ServerConsumer to use as a basis for the consumer information object.
        Returns:
        a new FederationConsumerInfo instance based on the server consumer
      • createConsumerEntry

        protected FederationQueueEntry createConsumerEntry​(FederationConsumerInfo consumerInfo)
        Creates a FederationQueueEntry instance that will be used to store an instance of a FederationConsumer along with other state data needed to manage a federation consumer instance. A subclass can override this method to return a more customized entry type with additional state data.
        Parameters:
        consumerInfo - The consumer information that defines characteristics of the federation queue consumer
        Returns:
        a new FederationQueueEntry that holds the given queue name.
      • createFederationConsumerMatcher

        protected Predicate<org.apache.activemq.artemis.core.server.ServerConsumer> createFederationConsumerMatcher​(org.apache.activemq.artemis.core.server.ActiveMQServer server,
                                                                                                                    FederationReceiveFromQueuePolicy policy)
                                                                                                             throws ActiveMQException
        Creates a Predicate that should return true if the given consumer is a federation created consumer which should not be further federated.
        Parameters:
        server - The server instance for use in creating the filtering Predicate.
        policy - The configured Queue matching policy that can provide additional match criteria.
        Returns:
        a Predicate that will return true if the consumer should be filtered.
        Throws:
        ActiveMQException - if an error occurs while creating the new consumer filter.
      • signalBeforeCreateFederationConsumer

        protected abstract void signalBeforeCreateFederationConsumer​(FederationConsumerInfo info)
        Signal any registered plugins for this federation instance that a remote Queue consumer is being created.
        Parameters:
        info - The FederationConsumerInfo that describes the remote Queue consumer
      • signalAfterCreateFederationConsumer

        protected abstract void signalAfterCreateFederationConsumer​(FederationConsumer consumer)
        Signal any registered plugins for this federation instance that a remote Queue consumer has been created.
        Parameters:
        consumer - The FederationConsumerInfo that describes the remote Queue consumer
      • signalBeforeCloseFederationConsumer

        protected abstract void signalBeforeCloseFederationConsumer​(FederationConsumer consumer)
        Signal any registered plugins for this federation instance that a remote Queue consumer is about to be closed.
        Parameters:
        consumer - The FederationConsumer that that is about to be closed.
      • signalAfterCloseFederationConsumer

        protected abstract void signalAfterCloseFederationConsumer​(FederationConsumer consumer)
        Signal any registered plugins for this federation instance that a remote Queue consumer has now been closed.
        Parameters:
        consumer - The FederationConsumer that that has been closed.
      • isPluginBlockingFederationConsumerCreate

        protected abstract boolean isPluginBlockingFederationConsumerCreate​(org.apache.activemq.artemis.core.server.Queue queue)
        Query all registered plugins for this federation instance to determine if any wish to prevent a federation consumer from being created for the given Queue.
        Parameters:
        queue - The Queue that the federation queue manager is attempting to create a remote consumer for.
        Returns:
        true if any registered plugin signaled that creation should be suppressed.