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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact