Class FederationAddressPolicyManager
- java.lang.Object
-
- org.apache.activemq.artemis.protocol.amqp.federation.internal.FederationAddressPolicyManager
-
- All Implemented Interfaces:
ActiveMQServerAddressPlugin,ActiveMQServerBasePlugin,ActiveMQServerBindingPlugin
- Direct Known Subclasses:
AMQPFederationAddressPolicyManager
public abstract class FederationAddressPolicyManager extends Object implements ActiveMQServerBindingPlugin, ActiveMQServerAddressPlugin
Manager for a federation which has address federation configuration which requires monitoring broker addresses and diverts for demand and creating a consumer on the remote side to federate messages back to this peer. Address federation replicates messages from the remote broker's address to an address on this broker but only when there is local demand on that address. If there is no local demand then federation if already established is halted. The manager creates a remote consumer on the federated address without any filtering other than that required for internal functionality in order to allow for a single remote consumer which can federate all messages to the local side where the existing queues can apply any filtering they have in place.
-
-
Field Summary
Fields Modifier and Type Field Description protected FederationInternalfederationprotected Map<org.apache.activemq.artemis.core.postoffice.impl.DivertBinding,Set<SimpleString>>matchingDivertsprotected FederationReceiveFromAddressPolicypolicyprotected Map<FederationConsumerInfo,FederationConsumerEntry>remoteConsumersprotected org.apache.activemq.artemis.core.server.ActiveMQServerserver
-
Constructor Summary
Constructors Constructor Description FederationAddressPolicyManager(FederationInternal federation, FederationReceiveFromAddressPolicy addressPolicy)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidafterAddAddress(org.apache.activemq.artemis.core.server.impl.AddressInfo addressInfo, boolean reload)voidafterAddBinding(org.apache.activemq.artemis.core.postoffice.Binding binding)voidbeforeRemoveBinding(SimpleString bindingName, org.apache.activemq.artemis.core.transaction.Transaction tx, boolean deleteData)protected voidcheckBindingForMatch(org.apache.activemq.artemis.core.postoffice.Binding binding)protected FederationConsumerEntrycreateConsumerEntry(FederationConsumerInternal consumer)Creates aFederationConsumerEntryinstance that will be used to store aFederationConsumeralong with other state data needed to manage a federation consumer instance.protected abstract FederationConsumerInfocreateConsumerInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo address)Create a newFederationConsumerInfobased on the givenAddressInfoand the configuredFederationReceiveFromAddressPolicy.protected abstract FederationConsumerInternalcreateFederationConsumer(FederationConsumerInfo consumerInfo)Create a newFederationConsumerInternalinstance using the consumer information given.protected abstract booleanisPluginBlockingFederationConsumerCreate(org.apache.activemq.artemis.core.server.Divert divert, 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.protected abstract booleanisPluginBlockingFederationConsumerCreate(org.apache.activemq.artemis.core.server.impl.AddressInfo address)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.protected abstract booleanisPluginBlockingFederationConsumerCreate(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.protected voidreactIfAnyQueueBindingMatchesDivertTarget(org.apache.activemq.artemis.core.postoffice.impl.DivertBinding divertBinding)protected booleanreactIfBindingMatchesPolicy(org.apache.activemq.artemis.core.server.impl.AddressInfo address, org.apache.activemq.artemis.core.postoffice.QueueBinding binding)protected voidreactIfQueueBindingMatchesAnyDivertTarget(org.apache.activemq.artemis.core.postoffice.QueueBinding queueBinding)protected voidscanAllBindings()Scans all bindings and push them through the normal bindings checks that would be done on an add.protected abstract voidsignalAfterCloseFederationConsumer(FederationConsumer consumer)Signal any registered plugins for this federation instance that a remote Address consumer has now been closed.protected abstract voidsignalAfterCreateFederationConsumer(FederationConsumer consumer)Signal any registered plugins for this federation instance that a remote Address consumer has been created.protected abstract voidsignalBeforeCloseFederationConsumer(FederationConsumer consumer)Signal any registered plugins for this federation instance that a remote Address consumer is about to be closed.protected abstract voidsignalBeforeCreateFederationConsumer(FederationConsumerInfo info)Signal any registered plugins for this federation instance that a remote Address consumer is being created.voidstart()Start the address policy manager which will initiate a scan of all broker divert bindings and create and matching remote receivers.voidstop()Stops the address policy manager which will close any open remote receivers that are active for local queue demand.protected booleantestIfAddressMatchesPolicy(org.apache.activemq.artemis.core.server.impl.AddressInfo addressInfo)Performs the test against the configured address policy to check if the target address is a match or not.protected voidtryRemoveDemandOnAddress(org.apache.activemq.artemis.core.server.impl.AddressInfo addressInfo)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.artemis.core.server.plugin.ActiveMQServerAddressPlugin
afterRemoveAddress, afterUpdateAddress, beforeAddAddress, beforeRemoveAddress, beforeUpdateAddress
-
Methods inherited from interface org.apache.activemq.artemis.core.server.plugin.ActiveMQServerBasePlugin
init, registered, setInit, unregistered
-
Methods inherited from interface org.apache.activemq.artemis.core.server.plugin.ActiveMQServerBindingPlugin
afterRemoveBinding, beforeAddBinding
-
-
-
-
Field Detail
-
server
protected final org.apache.activemq.artemis.core.server.ActiveMQServer server
-
policy
protected final FederationReceiveFromAddressPolicy policy
-
remoteConsumers
protected final Map<FederationConsumerInfo,FederationConsumerEntry> remoteConsumers
-
federation
protected final FederationInternal federation
-
matchingDiverts
protected final Map<org.apache.activemq.artemis.core.postoffice.impl.DivertBinding,Set<SimpleString>> matchingDiverts
-
-
Constructor Detail
-
FederationAddressPolicyManager
public FederationAddressPolicyManager(FederationInternal federation, FederationReceiveFromAddressPolicy addressPolicy) throws ActiveMQException
- Throws:
ActiveMQException
-
-
Method Detail
-
start
public void start()
Start the address policy manager which will initiate a scan of all broker divert bindings and create and matching remote receivers. Start on a policy manager should only be called after its parentFederationis started and the federation connection has been established.
-
stop
public void stop()
Stops the address policy manager which will close any open remote receivers that are active for local queue demand. Stop should generally be called whenever the parentFederationloses its connection to the remote.
-
afterAddAddress
public void afterAddAddress(org.apache.activemq.artemis.core.server.impl.AddressInfo addressInfo, boolean reload)- Specified by:
afterAddAddressin interfaceActiveMQServerAddressPlugin
-
afterAddBinding
public void afterAddBinding(org.apache.activemq.artemis.core.postoffice.Binding binding)
- Specified by:
afterAddBindingin interfaceActiveMQServerBindingPlugin
-
beforeRemoveBinding
public void beforeRemoveBinding(SimpleString bindingName, org.apache.activemq.artemis.core.transaction.Transaction tx, boolean deleteData)
- Specified by:
beforeRemoveBindingin interfaceActiveMQServerBindingPlugin
-
tryRemoveDemandOnAddress
protected final void tryRemoveDemandOnAddress(org.apache.activemq.artemis.core.server.impl.AddressInfo addressInfo)
-
scanAllBindings
protected final void scanAllBindings()
Scans all bindings and push them through the normal bindings checks that would be done on an add. We filter here based on whether diverts are enabled just to reduce the result set but the check call should also filter as during normal operations divert bindings could be added.
-
checkBindingForMatch
protected final void checkBindingForMatch(org.apache.activemq.artemis.core.postoffice.Binding binding)
-
reactIfAnyQueueBindingMatchesDivertTarget
protected final void reactIfAnyQueueBindingMatchesDivertTarget(org.apache.activemq.artemis.core.postoffice.impl.DivertBinding divertBinding)
-
reactIfQueueBindingMatchesAnyDivertTarget
protected final void reactIfQueueBindingMatchesAnyDivertTarget(org.apache.activemq.artemis.core.postoffice.QueueBinding queueBinding)
-
reactIfBindingMatchesPolicy
protected final boolean reactIfBindingMatchesPolicy(org.apache.activemq.artemis.core.server.impl.AddressInfo address, org.apache.activemq.artemis.core.postoffice.QueueBinding binding)
-
testIfAddressMatchesPolicy
protected boolean testIfAddressMatchesPolicy(org.apache.activemq.artemis.core.server.impl.AddressInfo addressInfo)
Performs the test against the configured address policy to check if the target 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:
addressInfo- The address that is being tested for a policy match.- Returns:
trueif the address given is a match against the policy.
-
createConsumerInfo
protected abstract FederationConsumerInfo createConsumerInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo address)
Create a newFederationConsumerInfobased on the givenAddressInfoand the configuredFederationReceiveFromAddressPolicy. A subclass must override this method to return a consumer information object with the data used be that implementation.- Parameters:
address- TheAddressInfoto use as a basis for the consumer information object.- Returns:
- a new
FederationConsumerInfoinstance based on the given address.
-
createConsumerEntry
protected FederationConsumerEntry createConsumerEntry(FederationConsumerInternal consumer)
Creates aFederationConsumerEntryinstance that will be used to store aFederationConsumeralong 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:
consumer- TheFederationConsumerInternalinstance that will be housed in this entry.- Returns:
- a new
FederationConsumerEntrythat holds the given federation consumer.
-
createFederationConsumer
protected abstract FederationConsumerInternal createFederationConsumer(FederationConsumerInfo consumerInfo)
Create a newFederationConsumerInternalinstance using the consumer information given. This is called when local demand for a matched queue requires a new consumer to be created. This method by default will call the configured consumer factory function that was provided when the manager was created, a subclass can override this to perform additional actions for the create operation.- Parameters:
consumerInfo- TheFederationConsumerInfothat defines the consumer to be created.- Returns:
- a new
FederationConsumerInternalinstance that will reside in this manager.
-
signalBeforeCreateFederationConsumer
protected abstract void signalBeforeCreateFederationConsumer(FederationConsumerInfo info)
Signal any registered plugins for this federation instance that a remote Address consumer is being created.- Parameters:
info- TheFederationConsumerInfothat describes the remote Address consumer
-
signalAfterCreateFederationConsumer
protected abstract void signalAfterCreateFederationConsumer(FederationConsumer consumer)
Signal any registered plugins for this federation instance that a remote Address consumer has been created.- Parameters:
consumer- TheFederationConsumerInfothat describes the remote Address consumer
-
signalBeforeCloseFederationConsumer
protected abstract void signalBeforeCloseFederationConsumer(FederationConsumer consumer)
Signal any registered plugins for this federation instance that a remote Address consumer is about to be closed.- Parameters:
consumer- TheFederationConsumerthat that is about to be closed.
-
signalAfterCloseFederationConsumer
protected abstract void signalAfterCloseFederationConsumer(FederationConsumer consumer)
Signal any registered plugins for this federation instance that a remote Address consumer has now been closed.- Parameters:
consumer- TheFederationConsumerthat that has been closed.
-
isPluginBlockingFederationConsumerCreate
protected abstract boolean isPluginBlockingFederationConsumerCreate(org.apache.activemq.artemis.core.server.impl.AddressInfo address)
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:
address- The address on which the manager is intending to create a remote consumer for.- Returns:
- true if any registered plugin signaled that creation should be suppressed.
-
isPluginBlockingFederationConsumerCreate
protected abstract boolean isPluginBlockingFederationConsumerCreate(org.apache.activemq.artemis.core.server.Divert divert, 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:
divert- TheDivertthat triggered the manager to attempt to create a remote consumer.queue- TheQueuethat triggered the manager to attempt to create a remote consumer.- Returns:
- true if any registered plugin signaled that creation should be suppressed.
-
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- TheQueuethat triggered the manager to attempt to create a remote consumer.- Returns:
- true if any registered plugin signaled that creation should be suppressed.
-
-