ARTEMIS-1113 STOMP + management-address fix

This commit is contained in:
Justin Bertram 2017-04-14 20:24:06 -05:00 committed by Martyn Taylor
parent abc2716191
commit 82b6a9678d
3 changed files with 14 additions and 3 deletions

View File

@ -42,6 +42,7 @@ import org.apache.activemq.artemis.core.remoting.FailureListener;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
@ -289,9 +290,14 @@ public final class StompConnection implements RemotingConnection {
}
public void checkRoutingSemantics(String destination, RoutingType routingType) throws ActiveMQStompException {
Set<RoutingType> actualDeliveryModesOfAddress = manager.getServer().getAddressInfo(getSession().getCoreSession().removePrefix(SimpleString.toSimpleString(destination))).getRoutingTypes();
if (routingType != null && !actualDeliveryModesOfAddress.contains(routingType)) {
throw BUNDLE.illegalSemantics(routingType.toString(), actualDeliveryModesOfAddress.toString());
AddressInfo addressInfo = manager.getServer().getAddressInfo(getSession().getCoreSession().removePrefix(SimpleString.toSimpleString(destination)));
// may be null here if, for example, the management address is being checked
if (addressInfo != null) {
Set<RoutingType> actualDeliveryModesOfAddress = addressInfo.getRoutingTypes();
if (routingType != null && !actualDeliveryModesOfAddress.contains(routingType)) {
throw BUNDLE.illegalSemantics(routingType.toString(), actualDeliveryModesOfAddress.toString());
}
}
}

View File

@ -403,6 +403,9 @@ public class StompProtocolManager extends AbstractProtocolManager<StompFrame, St
}
public boolean destinationExists(String destination) {
if (server.getManagementService().getManagementAddress().toString().equals(destination)) {
return true;
}
return server.getPostOffice().getAddressInfo(SimpleString.toSimpleString(destination)) != null;
}

View File

@ -52,6 +52,7 @@ import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
import org.apache.activemq.artemis.tests.integration.mqtt.imported.FuseMQTTClientProvider;
@ -1422,6 +1423,7 @@ public class StompTest extends StompTestBase {
@Test
public void testGetManagementAttributeFromStomp() throws Exception {
server.getActiveMQServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
conn.connect(defUser, defPass);
subscribe(conn, null);