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;
}
}
Aggregations