diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java index 4e184db149..27b222b40e 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java @@ -23,6 +23,7 @@ import java.util.Map; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; +import org.apache.activemq.artemis.core.protocol.stomp.v10.StompFrameV10; /** * Represents all the data in a STOMP frame. @@ -107,7 +108,7 @@ public class StompFrame { head.append(Stomp.NEWLINE); // Output the headers. encodeHeaders(head); - if (bytesBody != null && bytesBody.length > 0 && !hasHeader(Stomp.Headers.CONTENT_LENGTH)) { + if (bytesBody != null && bytesBody.length > 0 && !hasHeader(Stomp.Headers.CONTENT_LENGTH) && !(this instanceof StompFrameV10)) { head.append(Stomp.Headers.CONTENT_LENGTH); head.append(Stomp.Headers.SEPARATOR); head.append(bytesBody.length); diff --git a/docs/user-manual/en/protocols-interoperability.md b/docs/user-manual/en/protocols-interoperability.md index 5b486d0f11..7e81e65409 100644 --- a/docs/user-manual/en/protocols-interoperability.md +++ b/docs/user-manual/en/protocols-interoperability.md @@ -384,18 +384,18 @@ destinations, the Stomp destinations must follow the same convention: Stomp is mainly a text-orientated protocol. To make it simpler to interoperate with JMS and Apache ActiveMQ Artemis Core API, our Stomp implementation checks for presence of the `content-length` header to decide how to map -a Stomp message to a JMS Message or a Core message. +a Stomp 1.0 message to a JMS Message or a Core message. -If the Stomp message does *not* have a `content-length` header, it will +If the Stomp 1.0 message does *not* have a `content-length` header, it will be mapped to a JMS *TextMessage* or a Core message with a *single nullable SimpleString in the body buffer*. -Alternatively, if the Stomp message *has* a `content-length` header, it +Alternatively, if the Stomp 1.0 message *has* a `content-length` header, it will be mapped to a JMS *BytesMessage* or a Core message with a *byte[] in the body buffer*. The same logic applies when mapping a JMS message or a Core message to -Stomp. A Stomp client can check the presence of the `content-length` +Stomp. A Stomp 1.0 client can check the presence of the `content-length` header to determine the type of the message body (String or bytes). #### Message IDs for Stomp messages diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java index f28f5b2fda..8ba369f475 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java @@ -595,6 +595,10 @@ public class StompTest extends StompTestBase { Assert.assertTrue(frame.indexOf("destination:") > 0); Assert.assertTrue(frame.indexOf(getName()) > 0); + Pattern cl = Pattern.compile("Content-length:\\s*(\\d+)", Pattern.CASE_INSENSITIVE); + Matcher cl_matcher = cl.matcher(frame); + Assert.assertFalse(cl_matcher.find()); + frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL; sendFrame(frame); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java index dfcd1b9d9e..3d7e5f57a5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java @@ -2002,6 +2002,8 @@ public class StompV11Test extends StompV11TestBase { ClientStompFrame frame = connV11.receiveFrame(); + assertEquals(getName().length(), Integer.parseInt(frame.getHeader("content-length"))); + this.ack(connV11, "sub1", frame); connV11.disconnect();