diff --git a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java index 013c1ec7dc..2029f8471f 100644 --- a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java +++ b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java @@ -214,16 +214,15 @@ public class LegacyFrameTranslator implements FrameTranslator { ActiveMQDestination fallback = ActiveMQDestination.getUnresolvableDestinationTransformer().transform(fallbackName); if (fallback != null) { destinationBuilder.append(fallback.getQualifiedName()); - continue; } } catch (JMSException e) { throw new ProtocolException("Illegal destination name: [" + fallbackName + "] -- ActiveMQ STOMP destinations " + "must begin with one of: /queue/ /topic/ /temp-queue/ /temp-topic/", false, e); } + } else { + throw new ProtocolException("Illegal destination name: [" + originalName + "] -- ActiveMQ STOMP destinations " + + "must begin with one of: /queue/ /topic/ /temp-queue/ /temp-topic/"); } - - throw new ProtocolException("Illegal destination name: [" + originalName + "] -- ActiveMQ STOMP destinations " - + "must begin with one of: /queue/ /topic/ /temp-queue/ /temp-topic/"); } if (i < destinations.length - 1) { diff --git a/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompCompositeDestinationTest.java b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompCompositeDestinationTest.java index 223a84a2b6..bc84b5693d 100644 --- a/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompCompositeDestinationTest.java +++ b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompCompositeDestinationTest.java @@ -28,6 +28,7 @@ import javax.jms.JMSException; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; +import javax.management.ObjectName; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.broker.jmx.BrokerViewMBean; @@ -233,6 +234,51 @@ public class StompCompositeDestinationTest extends StompTestSupport { stompConnection.disconnect(); } + @Test(timeout = 60000) + public void testSendMessageToCompositeQueueNoPrefixes() throws Exception { + stompConnect(); + + String destinationA = "StompA.Queue"; + String destinationB = "StompB.Queue"; + + String frame = "CONNECT\n" + + "login:system\n" + + "passcode:manager\n\n" + Stomp.NULL; + stompConnection.sendFrame(frame); + + frame = stompConnection.receiveFrame(); + assertTrue(frame.startsWith("CONNECTED")); + + frame = "SEND\n" + + "destination:" + destinationA + "," + destinationB + + "\n\n" + "Hello World" + Stomp.NULL; + + stompConnection.sendFrame(frame); + + final BrokerViewMBean brokerView = getProxyToBroker(); + assertTrue("Should be two destinations for the dispatch", Wait.waitFor(new Wait.Condition() { + + @Override + public boolean isSatisified() throws Exception { + for(ObjectName queueName : brokerView.getQueues()) { + LOG.info("Broker Has Queue: {}", queueName); + } + return brokerView.getQueues().length == 2; + } + }, TimeUnit.SECONDS.toMillis(30), TimeUnit.MILLISECONDS.toMillis(150))); + + QueueViewMBean viewOfA = getProxyToQueue(destinationA); + QueueViewMBean viewOfB = getProxyToQueue(destinationB); + + assertNotNull(viewOfA); + assertNotNull(viewOfB); + + assertEquals(1, viewOfA.getQueueSize()); + assertEquals(1, viewOfB.getQueueSize()); + + stompConnection.disconnect(); + } + @Test(timeout = 60000) public void testSendMessageToCompositeTopic() throws Exception { stompConnect();