Search in sources :

Example 1 with ActiveMQAddressDoesNotExistException

use of org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException in project activemq-artemis by apache.

the class JMSServerManagerImpl method destroyTopic.

@Override
public synchronized boolean destroyTopic(final String name, final boolean removeConsumers) throws Exception {
    checkInitialised();
    AddressControl addressControl = (AddressControl) server.getManagementService().getResource(ResourceNames.ADDRESS + name);
    if (addressControl != null) {
        for (String queueName : addressControl.getQueueNames()) {
            Binding binding = server.getPostOffice().getBinding(new SimpleString(queueName));
            if (binding == null) {
                ActiveMQJMSServerLogger.LOGGER.noQueueOnTopic(queueName, name);
                continue;
            }
            // We can't remove the remote binding. As this would be the bridge associated with the topic on this case
            if (binding.getType() != BindingType.REMOTE_QUEUE) {
                server.destroyQueue(SimpleString.toSimpleString(queueName), null, !removeConsumers, removeConsumers, true);
            }
        }
        if (addressControl.getQueueNames().length == 0) {
            try {
                server.removeAddressInfo(SimpleString.toSimpleString(name), null);
            } catch (ActiveMQAddressDoesNotExistException e) {
            // ignore
            }
            removeFromBindings(topics, topicBindings, name);
            topics.remove(name);
            topicBindings.remove(name);
            storage.deleteDestination(PersistedType.Topic, name);
            sendNotification(JMSNotificationType.TOPIC_DESTROYED, name);
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Also used : AddressControl(org.apache.activemq.artemis.api.core.management.AddressControl) Binding(org.apache.activemq.artemis.core.postoffice.Binding) ActiveMQAddressDoesNotExistException(org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Aggregations

ActiveMQAddressDoesNotExistException (org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 AddressControl (org.apache.activemq.artemis.api.core.management.AddressControl)1 Binding (org.apache.activemq.artemis.core.postoffice.Binding)1