orpiske commented on code in PR #13273:
URL: https://github.com/apache/camel/pull/13273#discussion_r1499458392


##########
core/camel-main/src/main/java/org/apache/camel/main/MainDurationEventNotifier.java:
##########
@@ -110,10 +121,19 @@ protected void doNotify(CamelEvent event) {
             if (complete) {
                 doneMessages.increment();
                 final int doneCount = doneMessages.intValue();
-                final boolean result = doneCount >= maxMessages;
+                final int inflight = 
camelContext.getInflightRepository().size();
+
+                boolean result = doneCount >= maxMessages;
+                if (result && !maxMessagesIgnoreInflightExchanges) {
+                    result = inflight == 0;
+                }
 
                 if (LOG.isTraceEnabled()) {
-                    LOG.trace("Duration max messages check {} >= {} -> {}", 
doneCount, maxMessages, result);
+                    if (!maxMessagesIgnoreInflightExchanges) {
+                        LOG.trace("Duration max messages check {}/{} >= {} -> 
{}", doneCount, inflight, maxMessages, result);
+                    } else {
+                        LOG.trace("Duration max messages check {} >= {} -> 
{}", doneCount, maxMessages, result);
+                    }

Review Comment:
   I'm wondering if we could have this in a way that retains the old logic. If 
you are processing a large batch of messages using the main, this part gets 
called quite a lot. So, this part was adjusted along with the performance fixes 
done around 4.0.0 development. 
   
   As it is now, it is forcing the code to hit a path that is costlier (i.e.; 
the inflight repository instance is volatile, then the call itself may or many 
not be inlined as the JIT may not be able to determine its type, etc). 
   
   So, I think having 2 separate methods would be better here.



-- 
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: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to