This is an automated email from the ASF dual-hosted git repository.
robbie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 70c84ad6e7 ARTEMIS-5183 STOMP noLocal filter ignores legitimate
messages
70c84ad6e7 is described below
commit 70c84ad6e7a4595e7b217d1723000a33f7d01640
Author: Justin Bertram <[email protected]>
AuthorDate: Wed Dec 18 09:35:50 2024 -0600
ARTEMIS-5183 STOMP noLocal filter ignores legitimate messages
---
.../core/protocol/stomp/StompConnection.java | 2 +-
.../artemis/tests/integration/stomp/StompTest.java | 33 ++++++++++++++++++++--
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git
a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
index 9b397a7338..a9a474f8c7 100644
---
a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
+++
b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
@@ -565,7 +565,7 @@ public final class StompConnection extends
AbstractRemotingConnection {
checkDestination(destination);
checkRoutingSemantics(destination, subscriptionType);
if (noLocal) {
- String noLocalFilter = CONNECTION_ID_PROPERTY_NAME_STRING + " <> '" +
getID().toString() + "'";
+ String noLocalFilter = "(" + CONNECTION_ID_PROPERTY_NAME_STRING + "
<> '" + getID().toString() + "' OR " + CONNECTION_ID_PROPERTY_NAME_STRING + "
IS NULL)";
if (selector == null) {
selector = noLocalFilter;
} else {
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 d972e50d6c..1f84cd8d82 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
@@ -1480,7 +1480,7 @@ public class StompTest extends StompTestBase {
}
@Test
- public void testSubscribeToTopicWithNoLocal() throws Exception {
+ public void testSubscribeToTopicWithNoLocalSendWithJMS() throws Exception {
conn.connect(defUser, defPass);
subscribeTopic(conn, null, null, null, true, true);
@@ -1488,10 +1488,10 @@ public class StompTest extends StompTestBase {
send(conn, getTopicPrefix() + getTopicName(), null, "Hello World");
ClientStompFrame frame = conn.receiveFrame(100);
- logger.debug("Received frame: {}", frame);
assertNull(frame, "No message should have been received since
subscription was removed");
// send message on another JMS connection => it should be received
+ // a JMS message automatically gets a property named __AMQ_CID
sendJmsMessage(getName(), topic);
frame = conn.receiveFrame(10000);
assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
@@ -1501,6 +1501,35 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
+ @Test
+ public void testSubscribeToTopicWithNoLocalSendWithStomp() throws Exception
{
+ conn.connect(defUser, defPass);
+ StompClientConnection conn2 =
StompClientConnectionFactory.createClientConnection(uri);
+ conn2.connect(defUser, defPass);
+
+ try {
+ subscribeTopic(conn, null, null, null, true, true);
+
+ // send a message on the same connection => it should not be received
as noLocal = true on subscribe
+ send(conn, getTopicPrefix() + getTopicName(), null, "Hello World");
+
+ ClientStompFrame frame = conn.receiveFrame(100);
+ assertNull(frame, "No message should have been received since
subscription specified noLocal");
+
+ // send message on another STOMP connection => it should be received
+ // a STOMP message does *not* automatically get a property named
__AMQ_CID if there aren't any noLocal subscriptions on the connection
+ send(conn2, getTopicPrefix() + getTopicName(), null, getName());
+ frame = conn.receiveFrame(10000);
+ assertNotNull(frame);
+ assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
+ assertEquals(getTopicPrefix() + getTopicName(),
frame.getHeader(Stomp.Headers.Send.DESTINATION));
+ assertEquals(getName(), frame.getBody());
+ } finally {
+ conn.disconnect();
+ conn2.disconnect();
+ }
+ }
+
@Test
public void testSubscribeToTopicWithNoLocalAndSelector() throws Exception {
conn.connect(defUser, defPass);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact