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

cshannon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/main by this push:
     new 85502a526 AMQ-9157 - Dispatched advisory should not fire for queue 
browsers
85502a526 is described below

commit 85502a526d2a98dcc926d3b61f114978ee1741c3
Author: Christopher L. Shannon (cshannon) <[email protected]>
AuthorDate: Tue Nov 15 10:06:19 2022 -0500

    AMQ-9157 - Dispatched advisory should not fire for queue browsers
    
    The dispatched advisory doesn't really make sense to send for queue
    browsers, just like we don't send a consumed advisory, as it's more of
    an admin type funtion to look at the contents of a queue but it's not a
    real consumer that is receiving and acking messages.
---
 .../org/apache/activemq/advisory/AdvisoryBroker.java     |  3 ++-
 .../java/org/apache/activemq/advisory/AdvisoryTests.java | 16 +++-------------
 2 files changed, 5 insertions(+), 14 deletions(-)

diff --git 
a/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
 
b/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
index 14c856413..7beb3995d 100644
--- 
a/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
+++ 
b/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
@@ -492,7 +492,8 @@ public class AdvisoryBroker extends BrokerFilter {
     public void messageDispatched(ConnectionContext context, Subscription sub, 
MessageReference messageReference) {
         super.messageDispatched(context, sub, messageReference);
         try {
-            if (!messageReference.isAdvisory()) {
+            //Don't dispatch for queue browsers
+            if (!messageReference.isAdvisory() && 
!sub.getConsumerInfo().isBrowser()) {
                 BaseDestination baseDestination = (BaseDestination) 
messageReference.getMessage().getRegionDestination();
                 ActiveMQTopic topic = 
AdvisorySupport.getMessageDispatchedAdvisoryTopic(baseDestination.getActiveMQDestination());
                 Message payload = messageReference.getMessage().copy();
diff --git 
a/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
 
b/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
index c5faafe3e..b6866b4b4 100644
--- 
a/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
+++ 
b/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
@@ -208,7 +208,7 @@ public class AdvisoryTests {
     }
 
     @Test(timeout = 60000)
-    public void testQueueBrowserDispatchedAdvisory() throws Exception {
+    public void testQueueBrowserDispatchedAdvisoryNotSent() throws Exception {
         Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
         Queue queue = s.createQueue(getClass().getName());
 
@@ -232,19 +232,9 @@ public class AdvisoryTests {
         assertTrue(enumeration.hasMoreElements());
         assertNotNull(enumeration.nextElement());
 
+        //We should not be sending an advisory for dispatching to a browser
         Message msg = advisoryConsumer.receive(1000);
-        assertNotNull(msg);
-        ActiveMQMessage message = (ActiveMQMessage) msg;
-        ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure();
-
-        //This should always be tcp:// because that is the transport that is 
used to connect even though
-        //the nio transport is the first one in the list
-        
assertTrue(((String)message.getProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL)).startsWith("tcp://"));
-        
assertEquals(message.getProperty(AdvisorySupport.MSG_PROPERTY_DESTINATION), 
((ActiveMQDestination) queue).getQualifiedName());
-
-        //Add assertion to make sure body is included for advisory topics
-        //when includeBodyForAdvisory is true
-        assertIncludeBodyForAdvisory(payload);
+        assertNull(msg);
     }
 
     private void testMessageConsumerAdvisory(ActiveMQDestination dest, 
Function<ActiveMQDestination, Topic> advisoryTopicSupplier) throws Exception {

Reply via email to