Do not autoDelete address if it was not autoCreated

This commit is contained in:
Martyn Taylor 2016-12-15 17:13:09 +00:00
parent 2d7b77ac1b
commit 55fbcfebf8
2 changed files with 11 additions and 5 deletions

View File

@ -21,6 +21,7 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException;
import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException; import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException;
import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.SimpleString;
@ -247,13 +248,18 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
boolean clientDefined = hasCapabilities(TOPIC, source) || hasCapabilities(QUEUE, source); boolean clientDefined = hasCapabilities(TOPIC, source) || hasCapabilities(QUEUE, source);
if (clientDefined) { if (clientDefined) {
multicast = hasCapabilities(TOPIC, source); multicast = hasCapabilities(TOPIC, source);
AddressInfo addressInfo = sessionSPI.getAddress(addressToUse); AddressQueryResult addressQueryResult = sessionSPI.addressQuery(addressToUse.toString(), defaultRoutingType, true);
Set<RoutingType> routingTypes = addressInfo.getRoutingTypes(); if (!addressQueryResult.isExists()) {
throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.sourceAddressDoesntExist();
}
Set<RoutingType> routingTypes = addressQueryResult.getRoutingTypes();
//if the client defines 1 routing type and the broker another then throw an exception //if the client defines 1 routing type and the broker another then throw an exception
if (multicast && !routingTypes.contains(RoutingType.MULTICAST)) { if (multicast && !routingTypes.contains(RoutingType.MULTICAST)) {
throw new ActiveMQAMQPIllegalStateException("Address " + addressInfo.getName() + " is not configured for topic support"); throw new ActiveMQAMQPIllegalStateException("Address " + addressToUse + " is not configured for topic support");
} else if (!multicast && !routingTypes.contains(RoutingType.ANYCAST)) { } else if (!multicast && !routingTypes.contains(RoutingType.ANYCAST)) {
throw new ActiveMQAMQPIllegalStateException("Address " + addressInfo.getName() + " is not configured for queue support"); throw new ActiveMQAMQPIllegalStateException("Address " + addressToUse + " is not configured for queue support");
} }
} else { } else {
//if not we look up the address //if not we look up the address

View File

@ -1767,7 +1767,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
queue.deleteQueue(removeConsumers); queue.deleteQueue(removeConsumers);
if (autoDeleteAddress && postOffice != null) { if (autoDeleteAddress && postOffice != null && getAddressInfo(address).isAutoCreated()) {
try { try {
removeAddressInfo(address, session); removeAddressInfo(address, session);
} catch (ActiveMQDeleteAddressException e) { } catch (ActiveMQDeleteAddressException e) {