[ 
https://issues.apache.org/jira/browse/AMQ-9692?focusedWorklogId=981400&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-981400
 ]

ASF GitHub Bot logged work on AMQ-9692:
---------------------------------------

                Author: ASF GitHub Bot
            Created on: 02/Sep/25 12:21
            Start Date: 02/Sep/25 12:21
    Worklog Time Spent: 10m 
      Work Description: cshannon commented on code in PR #1484:
URL: https://github.com/apache/activemq/pull/1484#discussion_r2315911868


##########
activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java:
##########
@@ -311,12 +312,24 @@ public final MessageStore getMessageStore() {
 
     @Override
     public boolean isActive() {
-        boolean isActive = destinationStatistics.getConsumers().getCount() > 0 
||
-                           destinationStatistics.getProducers().getCount() > 0;
-        if (isActive && isGcWithNetworkConsumers() && 
destinationStatistics.getConsumers().getCount() > 0) {
-            isActive = hasRegularConsumers(getConsumers());
+        if (destinationStatistics.getProducers().getCount() > 0) {
+            return true;
         }
-        return isActive;
+
+        var destinationActive = true;

Review Comment:
   This is not very efficient because it may need to iterate through the 
consumers more than once. The way this is written, it may iterate through the 
consumers twice if both isGcWithNetworkConsumers() and 
isGcWithOnlyWildcardConsumers() is true. 
   
   What would make more sense is to only iterate through the consumers one time 
and use the predicate API to specify what you are looking for. You could build 
a predicate that look for either a network consumer, or not a wildcard consumer 
or some combination quite easily using 
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/function/Predicate.html
 . This would also make it easy to expand the criteria in the future for other 
conditions. 
   
   If all the flags are off then we wouldn't need to iterate through the 
consumers at all.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 981400)
    Time Spent: 20m  (was: 10m)

> Support destination gc sweep of destinations with wild card consumers
> ---------------------------------------------------------------------
>
>                 Key: AMQ-9692
>                 URL: https://issues.apache.org/jira/browse/AMQ-9692
>             Project: ActiveMQ Classic
>          Issue Type: Improvement
>            Reporter: Matt Pavlovich
>            Assignee: Matt Pavlovich
>            Priority: Minor
>             Fix For: 6.2.0, 5.20.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Currently, a wild-card consumer can hold up a destination from being 
> automatically garbage collected. This change would add a policyEntry setting 
> to allow garbage collection if the destination only has wild card consumers



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
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