activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1170474 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/command/ main/java/org/apache/activemq/transport/stomp/ test/java/org/apache/activemq/transport/stomp/
Date Wed, 14 Sep 2011 08:32:56 GMT
Author: gtully
Date: Wed Sep 14 08:32:56 2011
New Revision: 1170474

URL: http://svn.apache.org/viewvc?rev=1170474&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3496 - make use of the org.apache.activemq.command.UnresolvedDestinationTransformer
to provide a default value for an unqualified destinations string for a stomp replyTo header

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DefaultUnresolvedDestinationTransformer.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/UnresolvedDestinationTransformer.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DefaultUnresolvedDestinationTransformer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DefaultUnresolvedDestinationTransformer.java?rev=1170474&r1=1170473&r2=1170474&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DefaultUnresolvedDestinationTransformer.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/DefaultUnresolvedDestinationTransformer.java
Wed Sep 14 08:32:56 2011
@@ -48,4 +48,9 @@ public class DefaultUnresolvedDestinatio
             throw new JMSException("Unresolvable destination: "  + e.getMessage() + ": "
+ dest);
         }
     }
+
+    @Override
+    public ActiveMQDestination transform(String dest) throws JMSException {
+        return new ActiveMQQueue(dest);
+    }
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/UnresolvedDestinationTransformer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/UnresolvedDestinationTransformer.java?rev=1170474&r1=1170473&r2=1170474&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/UnresolvedDestinationTransformer.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/UnresolvedDestinationTransformer.java
Wed Sep 14 08:32:56 2011
@@ -22,5 +22,5 @@ import javax.jms.JMSException;
 public interface UnresolvedDestinationTransformer {
 
     public ActiveMQDestination transform(Destination dest) throws JMSException;
-
+    public ActiveMQDestination transform(String dest) throws JMSException;
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java?rev=1170474&r1=1170473&r2=1170474&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java
Wed Sep 14 08:32:56 2011
@@ -187,6 +187,15 @@ public class LegacyFrameTranslator imple
         } else if (name.startsWith("/temp-topic/")) {
             return converter.createTempTopic(name);
         } else {
+            try {
+                ActiveMQDestination fallback = ActiveMQDestination.getUnresolvableDestinationTransformer().transform(name);
+                if (fallback != null) {
+                    return fallback;
+                }
+            } catch (JMSException e) {
+                 throw new ProtocolException("Illegal destination name: [" + name + "] --
ActiveMQ STOMP destinations "
+                                        + "must begin with one of: /queue/ /topic/ /temp-queue/
/temp-topic/", false, e);
+            }
             throw new ProtocolException("Illegal destination name: [" + name + "] -- ActiveMQ
STOMP destinations "
                                         + "must begin with one of: /queue/ /topic/ /temp-queue/
/temp-topic/");
         }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java?rev=1170474&r1=1170473&r2=1170474&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
Wed Sep 14 08:32:56 2011
@@ -1529,6 +1529,22 @@ public class StompTest extends Combinati
         assertEquals(stompMessage.getHeaders().get(Stomp.Headers.Message.ORIGINAL_DESTINATION),
"/queue/" + getQueueName());
     }
 
+    public void testDefaultJMSReplyToDest() throws Exception {
+        stompConnection.connect("system", "manager");
+
+        HashMap<String, String> headers = new HashMap<String, String>();
+        long timestamp = System.currentTimeMillis();
+        headers.put(Stomp.Headers.Send.REPLY_TO, "JustAString");
+        headers.put(Stomp.Headers.Send.PERSISTENT, "true");
+
+        stompConnection.send("/queue/" + getQueueName(), "msg-with-reply-to", null, headers);
+
+        stompConnection.subscribe("/queue/" + getQueueName());
+        StompFrame stompMessage = stompConnection.receive(1000);
+        assertNotNull(stompMessage);
+        assertEquals(""  + stompMessage, stompMessage.getHeaders().get(Stomp.Headers.Send.REPLY_TO),
"/queue/" + "JustAString");
+    }
+
     public void testPersistent() throws Exception {
         stompConnection.connect("system", "manager");
 



Mime
View raw message