Search in sources :

Example 1 with Address

use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.

the class WildcardAddressManager method getAddress.

private Address getAddress(final SimpleString address) {
    Address add = new AddressImpl(address, wildcardConfiguration);
    Address actualAddress;
    if (add.containsWildCard()) {
        actualAddress = wildCardAddresses.get(address);
    } else {
        actualAddress = addresses.get(address);
    }
    return actualAddress != null ? actualAddress : add;
}
Also used : Address(org.apache.activemq.artemis.core.postoffice.Address)

Example 2 with Address

use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.

the class WildcardAddressManager method removeAndUpdateAddressMap.

private synchronized void removeAndUpdateAddressMap(final Address address) throws Exception {
    // we only remove if there are no bindings left
    Bindings bindings = super.getBindingsForRoutingAddress(address.getAddress());
    if (bindings == null || bindings.getBindings().size() == 0) {
        List<Address> addresses = address.getLinkedAddresses();
        for (Address address1 : addresses) {
            address1.removeLinkedAddress(address);
            Bindings linkedBindings = super.getBindingsForRoutingAddress(address1.getAddress());
            if (linkedBindings == null || linkedBindings.getBindings().size() == 0) {
                removeAddress(address1);
            }
        }
        removeAddress(address);
    }
}
Also used : Address(org.apache.activemq.artemis.core.postoffice.Address) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings)

Example 3 with Address

use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.

the class WildcardAddressManager method removeBinding.

/**
 * If the address is a wild card then the binding will be removed from the actual mappings for any linked address.
 * otherwise it will be removed as normal.
 *
 * @param uniqueName the name of the binding to remove
 * @return true if this was the last mapping for a specific address
 */
@Override
public Binding removeBinding(final SimpleString uniqueName, Transaction tx) throws Exception {
    Binding binding = super.removeBinding(uniqueName, tx);
    if (binding != null) {
        Address add = getAddress(binding.getAddress());
        if (add.containsWildCard()) {
            for (Address theAddress : add.getLinkedAddresses()) {
                super.removeBindingInternal(theAddress.getAddress(), uniqueName);
            }
        }
        removeAndUpdateAddressMap(add);
    }
    return binding;
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) Address(org.apache.activemq.artemis.core.postoffice.Address)

Example 4 with Address

use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.

the class WildcardAddressManager method addAndUpdateAddressMap.

private synchronized Address addAndUpdateAddressMap(final SimpleString address) {
    Address add = new AddressImpl(address, wildcardConfiguration);
    Address actualAddress;
    if (add.containsWildCard()) {
        actualAddress = wildCardAddresses.get(address);
    } else {
        actualAddress = addresses.get(address);
    }
    if (actualAddress == null) {
        actualAddress = add;
        addAddress(address, actualAddress);
    }
    if (actualAddress.containsWildCard()) {
        for (Address destAdd : addresses.values()) {
            if (destAdd.matches(actualAddress)) {
                destAdd.addLinkedAddress(actualAddress);
                actualAddress.addLinkedAddress(destAdd);
            }
        }
    } else {
        for (Address destAdd : wildCardAddresses.values()) {
            if (actualAddress.matches(destAdd)) {
                destAdd.addLinkedAddress(actualAddress);
                actualAddress.addLinkedAddress(destAdd);
            }
        }
    }
    return actualAddress;
}
Also used : Address(org.apache.activemq.artemis.core.postoffice.Address)

Example 5 with Address

use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.

the class WildcardAddressManager method updateMessageLoadBalancingTypeForAddress.

@Override
public void updateMessageLoadBalancingTypeForAddress(SimpleString address, MessageLoadBalancingType messageLoadBalancingType) throws Exception {
    Address add = addAndUpdateAddressMap(address);
    Bindings bindingsForRoutingAddress = super.getBindingsForRoutingAddress(address);
    if (bindingsForRoutingAddress != null) {
        bindingsForRoutingAddress.setMessageLoadBalancingType(messageLoadBalancingType);
    }
    if (add.containsWildCard()) {
        for (Address destAdd : add.getLinkedAddresses()) {
            getBindingsForRoutingAddress(destAdd.getAddress()).setMessageLoadBalancingType(messageLoadBalancingType);
        }
    } else {
        for (Address destAdd : add.getLinkedAddresses()) {
            super.getBindingsForRoutingAddress(destAdd.getAddress()).setMessageLoadBalancingType(messageLoadBalancingType);
        }
    }
}
Also used : Address(org.apache.activemq.artemis.core.postoffice.Address) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings)

Aggregations

Address (org.apache.activemq.artemis.core.postoffice.Address)31 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)24 Test (org.junit.Test)24 AddressImpl (org.apache.activemq.artemis.core.postoffice.impl.AddressImpl)23 Bindings (org.apache.activemq.artemis.core.postoffice.Bindings)4 Binding (org.apache.activemq.artemis.core.postoffice.Binding)3 Field (java.lang.reflect.Field)1 Map (java.util.Map)1 QueueBinding (org.apache.activemq.artemis.core.postoffice.QueueBinding)1 WildcardAddressManager (org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager)1 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)1 CompositeAddress (org.apache.activemq.artemis.utils.CompositeAddress)1