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

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

                Author: ASF GitHub Bot
            Created on: 22/Jan/26 14:38
            Start Date: 22/Jan/26 14:38
    Worklog Time Spent: 10m 
      Work Description: cshannon commented on code in PR #1484:
URL: https://github.com/apache/activemq/pull/1484#discussion_r2717182229


##########
activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java:
##########
@@ -311,12 +313,27 @@ 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;
+        if (destinationStatistics.getConsumers().getCount() > 0) {
+            Predicate<Subscription> isActiveConsumer = subscription -> {

Review Comment:
   ```java
   @Override
   public boolean isActive() {
       // if we have producers then we are active
       if (destinationStatistics.getProducers().getCount() > 0) {
           return true;
       }
   
       // Check if we have active consumers that should prevent GC
       if (destinationStatistics.getConsumers().getCount() > 0) {
           // if we have consumers and both gcWithNetwork and gcOnlyWildcard 
consumers
           // are false we can just return true, otherwise we need to check 
each consumer
           return (!isGcWithNetworkConsumers() && 
!isGcWithOnlyWildcardConsumers()) ||
                   hasActiveConsumers();
       }
       
       return false;
   }
   
   protected Predicate<Subscription> canGcConsumer = subscription -> {
       // if isGcWithNetworkConsumers() is true and this is a network 
subscription then we can GC
       boolean canGcNetwork = isGcWithNetworkConsumers() && 
subscription.getConsumerInfo().isNetworkSubscription();
       // if isGcWithOnlyWildcardConsumers() is true and this is a wildcard 
then we can GC
       return canGcNetwork || (isGcWithOnlyWildcardConsumers() && 
subscription.isWildcard());
   };
   
   protected boolean hasActiveConsumers() {
       final List<Subscription> consumers = getConsumers();
       for (Subscription subscription: consumers) {
           if (!canGcConsumer.test(subscription)) {
               return true;
           }
       }
       return false;
   }
   ```





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

    Worklog Id:     (was: 1001364)
    Time Spent: 1h 20m  (was: 1h 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
>          Issue Type: Improvement
>            Reporter: Matt Pavlovich
>            Assignee: Matt Pavlovich
>            Priority: Minor
>             Fix For: 6.3.0, 5.19.2
>
>          Time Spent: 1h 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