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

mattrpav 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 fc5a739f97 [#2275] Drop redundant consumers monitor from topic 
dispatch empty-check (#2281)
fc5a739f97 is described below

commit fc5a739f97cc3f5ae1ac21270d76ee6a91872c0a
Author: Matt Pavlovich <[email protected]>
AuthorDate: Mon Aug 10 21:17:11 2026 -0500

    [#2275] Drop redundant consumers monitor from topic dispatch empty-check 
(#2281)
---
 .../main/java/org/apache/activemq/broker/region/Topic.java    | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java 
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java
index 714f95ef69..fea004093e 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java
@@ -860,11 +860,12 @@ public class Topic extends BaseDestination implements 
Task {
                 }
             }
 
-            synchronized (consumers) {
-                if (consumers.isEmpty()) {
-                    onMessageWithNoConsumers(context, message);
-                    return;
-                }
+            // CopyOnWriteArrayList.isEmpty() is a volatile snapshot read; no
+            // monitor needed — the check is advisory at message granularity
+            // either way (subscription cutover is quiesced by dispatchLock).
+            if (consumers.isEmpty()) {
+                onMessageWithNoConsumers(context, message);
+                return;
             }
 
             // Clear memory before dispatch - need to clear here because the 
call to


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to