cshannon commented on code in PR #1484:
URL: https://github.com/apache/activemq/pull/1484#discussion_r2717190805
##########
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:
That is a suggestion on how we could write it, I played around with the
logic a bit and i found it less confusing to write a predicate that checked if
the consumer could be GC'd vs is active . The predicate returns true if either
can gc network flag is true and it's a network consumer, or if the gc with only
wildcard flag is true and the subscription is a wildcard.
It also optimizes by doing an initial check to see if either flag is true
and if both are false we can skip iteration entirely. I used a for each loop vs
streams just for the slight performance boost as isActive() will probably be
called a lot on each destination (although streams would be a lot cleaner)
--
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