This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 9eed41531f08 CAMEL-22923: camel-jbang - Capturing last message in 
backlog tracer may hit 1000 limit
9eed41531f08 is described below

commit 9eed41531f089b17c50cab5219259f6c48518e67
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Jan 29 13:18:19 2026 +0100

    CAMEL-22923: camel-jbang - Capturing last message in backlog tracer may hit 
1000 limit
---
 .../main/java/org/apache/camel/impl/debugger/BacklogTracer.java   | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java
index 3e70af452a7b..3f75319df11e 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java
@@ -60,7 +60,7 @@ public class BacklogTracer extends ServiceSupport implements 
org.apache.camel.sp
     private int backlogSize = 100;
     // use tracer to capture additional information for capturing latest 
completed exchange message-history
     private final Queue<BacklogTracerEventMessage> provisionalHistoryQueue = 
new LinkedBlockingQueue<>(MAX_BACKLOG_SIZE);
-    private final Queue<BacklogTracerEventMessage> completeHistoryQueue = new 
LinkedBlockingQueue<>(MAX_BACKLOG_SIZE);
+    private final Queue<BacklogTracerEventMessage> completeHistoryQueue = new 
LinkedBlockingQueue<>(MAX_BACKLOG_SIZE + 1);
     private boolean removeOnDump = true;
     private int bodyMaxChars = 32 * 1024;
     private boolean bodyIncludeStreams;
@@ -154,12 +154,16 @@ public class BacklogTracer extends ServiceSupport 
implements org.apache.camel.sp
                 tid = head.getExchangeId();
             }
             if (tid == null || tid.equals(event.getExchangeId()) || 
tid.equals(event.getCorrelationExchangeId())) {
-                provisionalHistoryQueue.add(event);
+                boolean added = provisionalHistoryQueue.offer(event);
                 boolean original = head != null && event.getRouteId() != null 
&& event.getRouteId().equals(head.getRouteId());
                 if (event.isLast() && original) {
                     // only trigger completion when it's the original last
                     completeHistoryQueue.clear();
                     completeHistoryQueue.addAll(provisionalHistoryQueue);
+                    // in case we hit the limit then ensure the last is always 
added to the complete history
+                    if (!added) {
+                        completeHistoryQueue.add(event);
+                    }
                     provisionalHistoryQueue.clear();
                 }
             }

Reply via email to