activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r906101 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/stomp/FrameTranslator.java test/java/org/apache/activemq/transport/stomp/StompTest.java
Date Wed, 03 Feb 2010 16:09:42 GMT
Author: tabish
Date: Wed Feb  3 16:09:42 2010
New Revision: 906101

URL: http://svn.apache.org/viewvc?rev=906101&view=rev
Log:
Fix for: https://issues.apache.org/activemq/browse/AMQ-1817

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/FrameTranslator.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/transport/stomp/FrameTranslator.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/FrameTranslator.java?rev=906101&r1=906100&r2=906101&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/FrameTranslator.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/FrameTranslator.java
Wed Feb  3 16:09:42 2010
@@ -120,6 +120,9 @@
                 msg.setPersistent("true".equals(o));
             }
 
+            // Stomp specific headers
+            o = headers.remove(Stomp.Headers.RECEIPT_REQUESTED);
+            
             // now the general headers
             msg.setProperties(headers);
         }

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=906101&r1=906100&r2=906101&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 Feb  3 16:09:42 2010
@@ -273,6 +273,57 @@
         assertEquals("GroupID", "abc", amqMessage.getGroupID());
     }
 
+    public void testReceipts() throws Exception {
+
+        StompConnection receiver = new StompConnection();
+        URI connectUri = new URI(bindAddress);
+        receiver.open(createSocket(connectUri));
+        String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;
+        receiver.sendFrame(frame);
+
+        frame = receiver.receiveFrame();
+        assertTrue(frame.startsWith("CONNECTED"));
+
+        frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "ack:auto\n\n"
+ Stomp.NULL;
+        receiver.sendFrame(frame);
+
+        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:/queue/" + getQueueName() + "\n" + "receipt: msg-1\n"
+ "\n\n" + "Hello World" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+
+        frame = receiver.receiveFrame();
+        assertTrue(frame.startsWith("MESSAGE"));
+        assertTrue("Stomp Message does not contain receipt request", frame.indexOf(Stomp.Headers.RECEIPT_REQUESTED)
== -1);
+
+        frame = stompConnection.receiveFrame();
+        assertTrue(frame.startsWith("RECEIPT"));
+        assertTrue("Receipt contains correct receipt-id", frame.indexOf(Stomp.Headers.Response.RECEIPT_ID)
>= 0);
+
+        receiver.disconnect();
+
+
+        MessageConsumer consumer = session.createConsumer(queue);
+
+        frame = "SEND\n" + "destination:/queue/" + getQueueName() + "\n" + "receipt: msg-1\n"
+ "\n\n" + "Hello World" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+
+        frame = stompConnection.receiveFrame();
+        assertTrue(frame.startsWith("RECEIPT"));
+        assertTrue("Receipt contains correct receipt-id", frame.indexOf(Stomp.Headers.Response.RECEIPT_ID)
>= 0);
+
+        TextMessage message = (TextMessage)consumer.receive(2500);
+        assertNotNull(message);
+        assertNull("JMS Message does not contain receipt request", message.getStringProperty(Stomp.Headers.RECEIPT_REQUESTED));
+
+        stompConnection.disconnect();
+
+    }
+
     public void testSubscribeWithAutoAck() throws Exception {
 
         String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;



Mime
View raw message