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

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

commit 327a3197144173d6117b6e81670994095e678be3
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon May 18 12:48:23 2026 +0200

    Introduce SyntheticBacklogTracer SPI for components that bypass the route 
pipeline
    
    traceBeforeNode/traceAfterNode on BacklogTracer were too generic and hid the
    first/last semantics that drive message-history completion. Replaced with a
    dedicated SyntheticBacklogTracer sub-interface that exposes traceFirstNode 
and
    traceLastNode with explicit intent.
    
    - camel-api: new SyntheticBacklogTracer extends BacklogTracer with 
traceFirstNode/traceLastNode
    - camel-api: remove traceBeforeNode/traceAfterNode from BacklogTracer (only 
traceEvent kept)
    - camel-base-engine: BacklogTracer impl now implements 
SyntheticBacklogTracer
    - camel-rest-openapi: mock mode uses instanceof SyntheticBacklogTracer cast 
to call the new API
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
---
 .../openapi/DefaultRestOpenapiProcessorStrategy.java  | 14 ++++++++------
 .../main/java/org/apache/camel/spi/BacklogTracer.java | 19 +------------------
 .../org/apache/camel/impl/debugger/BacklogTracer.java |  6 +++---
 3 files changed, 12 insertions(+), 27 deletions(-)

diff --git 
a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/DefaultRestOpenapiProcessorStrategy.java
 
b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/DefaultRestOpenapiProcessorStrategy.java
index 638425cd2f57..7c289178a13b 100644
--- 
a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/DefaultRestOpenapiProcessorStrategy.java
+++ 
b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/DefaultRestOpenapiProcessorStrategy.java
@@ -45,6 +45,7 @@ import org.apache.camel.spi.BacklogTracer;
 import org.apache.camel.spi.PackageScanResourceResolver;
 import org.apache.camel.spi.ProducerCache;
 import org.apache.camel.spi.Resource;
+import org.apache.camel.spi.SyntheticBacklogTracer;
 import org.apache.camel.support.ExchangeHelper;
 import org.apache.camel.support.PluginHelper;
 import org.apache.camel.support.cache.DefaultProducerCache;
@@ -210,17 +211,18 @@ public class DefaultRestOpenapiProcessorStrategy extends 
ServiceSupport
                         exchange.setRouteStop(true);
                     } else if ("mock".equalsIgnoreCase(missingOperation)) {
                         // no route then try to load mock data as the answer
-                        BacklogTracer backlogTracer
-                                = 
camelContext.getCamelContextExtension().getContextPlugin(BacklogTracer.class);
+                        BacklogTracer bt = 
camelContext.getCamelContextExtension().getContextPlugin(BacklogTracer.class);
+                        SyntheticBacklogTracer syntheticTracer
+                                = bt instanceof SyntheticBacklogTracer s ? s : 
null;
                         NamedNode mockNode = new MockOperationNode(verb, path, 
operation.getOperationId());
-                        if (backlogTracer != null && 
(backlogTracer.isEnabled() || backlogTracer.isStandby())) {
-                            backlogTracer.traceBeforeNode(mockNode, exchange);
+                        if (syntheticTracer != null && 
(syntheticTracer.isEnabled() || syntheticTracer.isStandby())) {
+                            syntheticTracer.traceFirstNode(mockNode, exchange);
                         }
                         try {
                             loadMockData(operation, verb, path, exchange);
                         } finally {
-                            if (backlogTracer != null && 
(backlogTracer.isEnabled() || backlogTracer.isStandby())) {
-                                backlogTracer.traceAfterNode(mockNode, 
exchange);
+                            if (syntheticTracer != null && 
(syntheticTracer.isEnabled() || syntheticTracer.isStandby())) {
+                                syntheticTracer.traceLastNode(mockNode, 
exchange);
                             }
                         }
                     }
diff --git 
a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java 
b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java
index 4c514e2a9318..5dd19f16c1cf 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java
@@ -208,24 +208,7 @@ public interface BacklogTracer {
     boolean shouldTrace(NamedNode node, Exchange exchange);
 
     /**
-     * Trace a "before node" event for components that process exchanges 
inline and bypass the normal route pipeline
-     * (e.g. mock mode in rest-openapi consumer). The concrete implementation 
builds and stores the trace event.
-     *
-     * @since 4.21
-     */
-    void traceBeforeNode(NamedNode node, Exchange exchange);
-
-    /**
-     * Trace an "after node" event for components that process exchanges 
inline and bypass the normal route pipeline
-     * (e.g. mock mode in rest-openapi consumer). The concrete implementation 
builds and stores the trace event.
-     *
-     * @since 4.21
-     */
-    void traceAfterNode(NamedNode node, Exchange exchange);
-
-    /**
-     * Records a trace event. Used by components that handle processing inline 
(e.g. mock mode in rest-openapi consumer)
-     * and therefore bypass the normal route pipeline where tracing is applied 
automatically.
+     * Records a trace event. Used internally by the route pipeline advices to 
submit pre-built trace events.
      *
      * @since 4.21
      */
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 7f81c0295584..8cb028bbd0ff 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
@@ -48,7 +48,7 @@ import org.apache.camel.util.json.Jsoner;
  * This tracer allows to store message tracers per node in the Camel routes. 
The tracers is stored in a backlog queue
  * (FIFO based) which allows to pull the traced messages on demand.
  */
-public class BacklogTracer extends ServiceSupport implements 
org.apache.camel.spi.BacklogTracer {
+public class BacklogTracer extends ServiceSupport implements 
org.apache.camel.spi.SyntheticBacklogTracer {
 
     // limit the tracer to a thousand messages in total
     public static final int MAX_BACKLOG_SIZE = 1000;
@@ -143,12 +143,12 @@ public class BacklogTracer extends ServiceSupport 
implements org.apache.camel.sp
     }
 
     @Override
-    public void traceBeforeNode(NamedNode node, Exchange exchange) {
+    public void traceFirstNode(NamedNode node, Exchange exchange) {
         traceNode(node, exchange, true, false);
     }
 
     @Override
-    public void traceAfterNode(NamedNode node, Exchange exchange) {
+    public void traceLastNode(NamedNode node, Exchange exchange) {
         traceNode(node, exchange, false, true);
     }
 

Reply via email to