Search in sources :

Example 6 with Bindings

use of org.apache.activemq.artemis.core.postoffice.Bindings 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 7 with Bindings

use of org.apache.activemq.artemis.core.postoffice.Bindings 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 8 with Bindings

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

the class SimpleAddressManager method addMappingInternal.

protected boolean addMappingInternal(final SimpleString address, final Binding binding) throws Exception {
    Bindings bindings = mappings.get(address);
    Bindings prevBindings = null;
    if (bindings == null) {
        bindings = bindingsFactory.createBindings(address);
        prevBindings = mappings.putIfAbsent(address, bindings);
        if (prevBindings != null) {
            bindings = prevBindings;
        }
    }
    bindings.addBinding(binding);
    return prevBindings != null;
}
Also used : Bindings(org.apache.activemq.artemis.core.postoffice.Bindings)

Example 9 with Bindings

use of org.apache.activemq.artemis.core.postoffice.Bindings 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)

Example 10 with Bindings

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

the class OpenWireConnection method removeDestination.

public void removeDestination(ActiveMQDestination dest) throws Exception {
    if (dest.isQueue()) {
        try {
            server.destroyQueue(new SimpleString(dest.getPhysicalName()), getRemotingConnection());
        } catch (ActiveMQNonExistentQueueException neq) {
            // this is ok, ActiveMQ 5 allows this and will actually do it quite often
            ActiveMQServerLogger.LOGGER.debug("queue never existed");
        }
    } else {
        Bindings bindings = server.getPostOffice().getBindingsForAddress(new SimpleString(dest.getPhysicalName()));
        for (Binding binding : bindings.getBindings()) {
            Queue b = (Queue) binding.getBindable();
            if (b.getConsumerCount() > 0) {
                throw new Exception("Destination still has an active subscription: " + dest.getPhysicalName());
            }
            if (b.isDurable()) {
                throw new Exception("Destination still has durable subscription: " + dest.getPhysicalName());
            }
            b.deleteQueue();
        }
    }
    if (!AdvisorySupport.isAdvisoryTopic(dest)) {
        AMQConnectionContext context = getContext();
        DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.REMOVE_OPERATION_TYPE, dest);
        ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
        protocolManager.fireAdvisory(context, topic, advInfo);
    }
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) DestinationInfo(org.apache.activemq.command.DestinationInfo) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) AMQConnectionContext(org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) Bindings(org.apache.activemq.artemis.core.postoffice.Bindings) ActiveMQTempQueue(org.apache.activemq.command.ActiveMQTempQueue) Queue(org.apache.activemq.artemis.core.server.Queue) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQRemoteDisconnectException(org.apache.activemq.artemis.api.core.ActiveMQRemoteDisconnectException) IllegalStateException(javax.jms.IllegalStateException) XAException(javax.transaction.xa.XAException) InvalidDestinationException(javax.jms.InvalidDestinationException) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) IOException(java.io.IOException) ActiveMQAddressExistsException(org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException) ActiveMQSecurityException(org.apache.activemq.artemis.api.core.ActiveMQSecurityException) JMSSecurityException(javax.jms.JMSSecurityException) ActiveMQQueueExistsException(org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException) InvalidClientIDException(javax.jms.InvalidClientIDException)

Aggregations

Bindings (org.apache.activemq.artemis.core.postoffice.Bindings)35 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)24 Binding (org.apache.activemq.artemis.core.postoffice.Binding)22 QueueBinding (org.apache.activemq.artemis.core.postoffice.QueueBinding)15 LocalQueueBinding (org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding)12 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)7 Test (org.junit.Test)7 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)6 Queue (org.apache.activemq.artemis.core.server.Queue)6 RemoteQueueBinding (org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding)6 ArrayList (java.util.ArrayList)5 PostOffice (org.apache.activemq.artemis.core.postoffice.PostOffice)5 Connection (javax.jms.Connection)4 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)4 Address (org.apache.activemq.artemis.core.postoffice.Address)4 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)4 IOException (java.io.IOException)3 PrintWriter (java.io.PrintWriter)3 StringWriter (java.io.StringWriter)3 MessageConsumer (javax.jms.MessageConsumer)3