Search in sources :

Example 6 with Binding

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

the class BindingsImpl method addBinding.

@Override
public void addBinding(final Binding binding) {
    if (logger.isTraceEnabled()) {
        logger.trace("addBinding(" + binding + ") being called");
    }
    if (binding.isExclusive()) {
        exclusiveBindings.add(binding);
    } else {
        SimpleString routingName = binding.getRoutingName();
        List<Binding> bindings = routingNameBindingMap.get(routingName);
        if (bindings == null) {
            bindings = new CopyOnWriteArrayList<>();
            List<Binding> oldBindings = routingNameBindingMap.putIfAbsent(routingName, bindings);
            if (oldBindings != null) {
                bindings = oldBindings;
            }
        }
        if (!bindings.contains(binding)) {
            bindings.add(binding);
        }
    }
    bindingsMap.put(binding.getID(), binding);
    if (logger.isTraceEnabled()) {
        logger.trace("Adding binding " + binding + " into " + this + " bindingTable: " + debugBindings());
    }
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) RemoteQueueBinding(org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 7 with Binding

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

the class SimpleAddressManager method validateRoutingTypes.

private void validateRoutingTypes(SimpleString addressName, EnumSet<RoutingType> routingTypes) {
    final Bindings bindings = this.mappings.get(addressName);
    if (bindings != null) {
        for (Binding binding : bindings.getBindings()) {
            if (binding instanceof QueueBinding) {
                final QueueBinding queueBinding = (QueueBinding) binding;
                final RoutingType routingType = queueBinding.getQueue().getRoutingType();
                if (!routingTypes.contains(routingType) && binding.getAddress().equals(addressName)) {
                    throw ActiveMQMessageBundle.BUNDLE.invalidRoutingTypeDelete(routingType, addressName.toString());
                }
            }
        }
    }
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings) RoutingType(org.apache.activemq.artemis.api.core.RoutingType)

Example 8 with Binding

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

the class SimpleAddressManager method removeBinding.

@Override
public Binding removeBinding(final SimpleString uniqueName, Transaction tx) throws Exception {
    final Binding binding = nameMap.remove(uniqueName);
    if (binding == null) {
        return null;
    }
    removeBindingInternal(binding.getAddress(), uniqueName);
    return binding;
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding)

Example 9 with Binding

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

the class SimpleAddressManager method getMatchingBindings.

@Override
public Bindings getMatchingBindings(final SimpleString address) throws Exception {
    Address add = new AddressImpl(address, wildcardConfiguration);
    Bindings bindings = bindingsFactory.createBindings(address);
    for (Binding binding : nameMap.values()) {
        Address addCheck = new AddressImpl(binding.getAddress(), wildcardConfiguration);
        if (addCheck.matches(add)) {
            bindings.addBinding(binding);
        }
    }
    return bindings;
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) CompositeAddress(org.apache.activemq.artemis.utils.CompositeAddress) Address(org.apache.activemq.artemis.core.postoffice.Address) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings)

Example 10 with Binding

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

the class AddressControlImpl method getQueueNames.

@Override
public String[] getQueueNames() throws Exception {
    clearIO();
    try {
        Bindings bindings = postOffice.getBindingsForAddress(addressInfo.getName());
        List<String> queueNames = new ArrayList<>();
        for (Binding binding : bindings.getBindings()) {
            if (binding instanceof QueueBinding) {
                queueNames.add(binding.getUniqueName().toString());
            }
        }
        return queueNames.toArray(new String[queueNames.size()]);
    } catch (Throwable t) {
        throw new IllegalStateException(t.getMessage());
    } finally {
        blockOnIO();
    }
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) ArrayList(java.util.ArrayList) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings)

Aggregations

Binding (org.apache.activemq.artemis.core.postoffice.Binding)81 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)52 LocalQueueBinding (org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding)29 QueueBinding (org.apache.activemq.artemis.core.postoffice.QueueBinding)28 Test (org.junit.Test)25 Bindings (org.apache.activemq.artemis.core.postoffice.Bindings)24 Queue (org.apache.activemq.artemis.core.server.Queue)24 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)18 RemoteQueueBinding (org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding)17 ArrayList (java.util.ArrayList)12 Filter (org.apache.activemq.artemis.core.filter.Filter)10 DivertBinding (org.apache.activemq.artemis.core.postoffice.impl.DivertBinding)10 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)9 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)9 Map (java.util.Map)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 QueueQueryResult (org.apache.activemq.artemis.core.server.QueueQueryResult)8 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)7 PostOffice (org.apache.activemq.artemis.core.postoffice.PostOffice)7 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)7