activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1227577 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/stomp/ test/java/org/apache/activemq/transport/stomp/ test/resources/org/apache/activemq/transport/stomp/
Date Thu, 05 Jan 2012 13:00:01 GMT
Author: dejanb
Date: Thu Jan  5 13:00:00 2012
New Revision: 1227577

URL: http://svn.apache.org/viewvc?rev=1227577&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3653 - content-length in ack frames

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompWireFormat.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
    activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/stomp/stomp-auth-broker.xml

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompWireFormat.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompWireFormat.java?rev=1227577&r1=1227576&r2=1227577&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompWireFormat.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompWireFormat.java
Thu Jan  5 13:00:00 2012
@@ -16,21 +16,15 @@
  */
 package org.apache.activemq.transport.stomp;
 
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.DataOutput;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.activemq.util.ByteArrayInputStream;
 import org.apache.activemq.util.ByteArrayOutputStream;
 import org.apache.activemq.util.ByteSequence;
 import org.apache.activemq.wireformat.WireFormat;
 
+import java.io.*;
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Implements marshalling and unmarsalling the <a
  * href="http://stomp.codehaus.org/">Stomp</a> protocol.
@@ -103,7 +97,7 @@ public class StompWireFormat implements 
             // Read in the data part.
             byte[] data = NO_DATA;
             String contentLength = headers.get(Stomp.Headers.CONTENT_LENGTH);
-            if (contentLength != null) {
+            if ((action.equals(Stomp.Commands.SEND) || action.equals(Stomp.Responses.MESSAGE))
&& contentLength != null) {
 
                 // Bless the client, he's telling us how much data to read in.
                 int length = parseContentLength(contentLength);

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=1227577&r1=1227576&r2=1227577&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
Thu Jan  5 13:00:00 2012
@@ -729,6 +729,39 @@ public class StompTest extends Combinati
         assertTrue(message.getJMSRedelivered());
     }
 
+    public void testSubscribeWithClientAckAndContentLength() throws Exception {
+
+        String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+
+        frame = stompConnection.receiveFrame();
+        assertTrue(frame.startsWith("CONNECTED"));
+
+        frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "ack:client\n\n"
+ Stomp.NULL;
+
+        stompConnection.sendFrame(frame);
+        sendMessage(getName());
+        StompFrame msg = stompConnection.receive();
+
+
+        assertTrue(msg.getAction().equals("MESSAGE"));
+        
+        HashMap<String, String> ackHeaders = new HashMap<String, String>();
+        ackHeaders.put("message-id", msg.getHeaders().get("message-id"));
+        ackHeaders.put("content-length", "8511");
+
+        StompFrame ack = new StompFrame("ACK", ackHeaders);
+        stompConnection.sendFrame(ack.format());
+
+
+        stompDisconnect();
+
+        // message should not be received since it was acknowledged
+        MessageConsumer consumer = session.createConsumer(queue);
+        TextMessage message = (TextMessage)consumer.receive(500);
+        assertNull(message);
+    }
+
     public void testUnsubscribe() throws Exception {
 
         String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;

Modified: activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/stomp/stomp-auth-broker.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/stomp/stomp-auth-broker.xml?rev=1227577&r1=1227576&r2=1227577&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/stomp/stomp-auth-broker.xml
(original)
+++ activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/stomp/stomp-auth-broker.xml
Thu Jan  5 13:00:00 2012
@@ -68,7 +68,7 @@
     </plugins>
     
     <transportConnectors>
-		<transportConnector name="stomp"   uri="stomp://localhost:61613?transport.keepAlive=true&amp;transport.soLinger=0"/>
+		<transportConnector name="stomp"   uri="stomp://localhost:61613?trace=true&amp;transport.keepAlive=true&amp;transport.soLinger=0"/>
 	</transportConnectors>
     
   </broker>



Mime
View raw message