You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2024/07/19 20:00:50 UTC

(activemq-artemis) branch main updated: ARTEMIS-4912 filter not enforced when sending msg to q via web console

This is an automated email from the ASF dual-hosted git repository.

jbertram 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 4e1daccfe3 ARTEMIS-4912 filter not enforced when sending msg to q via web console
4e1daccfe3 is described below

commit 4e1daccfe3ef7c911b0635fc5f18088855e88a24
Author: Justin Bertram <jb...@apache.org>
AuthorDate: Tue Jul 9 10:33:53 2024 -0500

    ARTEMIS-4912 filter not enforced when sending msg to q via web console
---
 .../artemis/core/management/impl/AbstractControl.java     | 14 +-------------
 .../artemis/core/management/impl/QueueControlImpl.java    |  3 ++-
 .../tests/integration/management/QueueControlTest.java    | 15 +++++++++++++++
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AbstractControl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AbstractControl.java
index 810a79aced..275c2b4380 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AbstractControl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AbstractControl.java
@@ -21,7 +21,6 @@ import javax.management.MBeanInfo;
 import javax.management.MBeanOperationInfo;
 import javax.management.NotCompliantMBeanException;
 import javax.management.StandardMBean;
-import java.nio.ByteBuffer;
 import java.util.Collections;
 import java.util.Map;
 import java.util.concurrent.Callable;
@@ -114,8 +113,7 @@ public abstract class AbstractControl extends StandardMBean {
                                 boolean durable,
                                 String user,
                                 String password,
-                                boolean createMessageId,
-                                Long...queueID) throws Exception {
+                                boolean createMessageId) throws Exception {
       ManagementRemotingConnection fakeConnection = new ManagementRemotingConnection();
       final String validatedUser = server.validateUser(user, password, fakeConnection, null);
       ServerSession serverSession = server.createSession("management::" + UUIDGenerator.getInstance().generateStringUUID(), user, password,
@@ -143,16 +141,6 @@ public abstract class AbstractControl extends StandardMBean {
 
          message.setAddress(address);
 
-         // if a queueID is used, we set the routeToIDs property
-         // to one or many specific queues
-         if (queueID != null && queueID.length > 0) {
-            ByteBuffer buffer = ByteBuffer.allocate(8 * queueID.length);
-            for (Long q : queueID) {
-               buffer.putLong(q);
-            }
-            message.putBytesProperty(Message.HDR_ROUTE_TO_IDS, buffer.array());
-         }
-
          if (createMessageId) {
             UUID userID = UUIDGenerator.getInstance().generateUUID();
             message.setUserID(userID);
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
index d99b0a8526..2a010017c1 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
@@ -61,6 +61,7 @@ import org.apache.activemq.artemis.json.JsonArrayBuilder;
 import org.apache.activemq.artemis.json.JsonObjectBuilder;
 import org.apache.activemq.artemis.logs.AuditLogger;
 import org.apache.activemq.artemis.selector.filter.Filterable;
+import org.apache.activemq.artemis.utils.CompositeAddress;
 import org.apache.activemq.artemis.utils.JsonLoader;
 import org.apache.activemq.artemis.utils.collections.LinkedListIterator;
 import org.slf4j.Logger;
@@ -1456,7 +1457,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
             AuditLogger.sendMessageThroughManagement(queue, headers, type, body, durable, user, "****");
          }
          try {
-            String s = sendMessage(queue.getAddress(), server, headers, type, body, durable, user, password, createMessageId, queue.getID());
+            String s = sendMessage(CompositeAddress.toFullyQualified(queue.getAddress(), queue.getName()), server, headers, type, body, durable, user, password, createMessageId);
             if (AuditLogger.isResourceLoggingEnabled()) {
                AuditLogger.sendMessageSuccess(queue.getName().toString(), user);
             }
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
index fc7608292f..6289bc7719 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
@@ -4293,6 +4293,21 @@ public class QueueControlTest extends ManagementTestBase {
       assertEquals(new String(body), "theBody");
    }
 
+   @TestTemplate
+   public void testSendMessageToQueueWithFilter() throws Exception {
+      SimpleString address = RandomUtil.randomSimpleString();
+      SimpleString queue = RandomUtil.randomSimpleString();
+
+      session.createQueue(QueueConfiguration.of(queue).setAddress(address).setDurable(durable).setFilterString("foo = 'foo'"));
+
+      QueueControl queueControl = createManagementControl(address, queue);
+
+      queueControl.sendMessage(new HashMap<>(), Message.BYTES_TYPE, Base64.encodeBytes("theBody".getBytes()), true, "myUser", "myPassword");
+      queueControl.sendMessage(Map.of("foo", "foo"), Message.BYTES_TYPE, Base64.encodeBytes("theBody".getBytes()), true, "myUser", "myPassword");
+
+      Wait.assertEquals(1, () -> getMessageCount(queueControl));
+   }
+
    @TestTemplate
    public void testSendMessageWithProperties() throws Exception {
       SimpleString address = RandomUtil.randomSimpleString();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact