NO-JIRA Fix Issue with Auto Create Address

This commit is contained in:
Martyn Taylor 2016-12-16 14:52:24 +00:00 committed by jbertram
parent be38f4dd45
commit 3e0ad2268b
1 changed files with 10 additions and 4 deletions

View File

@ -2531,10 +2531,16 @@ public class ActiveMQServerImpl implements ActiveMQServer {
AddressInfo info = postOffice.getAddressInfo(addressName);
if (autoCreateAddress) {
if (info == null || !info.getRoutingTypes().contains(routingType)) {
final AddressInfo defaultAddressInfo = new AddressInfo(addressName);
defaultAddressInfo.addRoutingType(routingType == null ? ActiveMQDefaultConfiguration.getDefaultRoutingType() : routingType);
createOrUpdateAddressInfo(defaultAddressInfo.setAutoCreated(true));
RoutingType rt = (routingType == null ? ActiveMQDefaultConfiguration.getDefaultRoutingType() : routingType);
if (info == null) {
final AddressInfo addressInfo = new AddressInfo(addressName, rt);
createAddressInfo(addressInfo);
}
else if (!info.getRoutingTypes().contains(routingType)) {
Set<RoutingType> routingTypes = new HashSet<>();
routingTypes.addAll(info.getRoutingTypes());
routingTypes.add(routingType);
updateAddressInfo(info.getName().toString(), routingTypes);
}
} else if (info == null) {
throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(addressName);