You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/12/12 18:13:18 UTC
(camel) branch main updated: CAMEL-20206: split overly complex method in CamelInternalProcessor (#12426)
This is an automated email from the ASF dual-hosted git repository.
orpiske 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 44b7790ec5f CAMEL-20206: split overly complex method in CamelInternalProcessor (#12426)
44b7790ec5f is described below
commit 44b7790ec5f624632e87f7bd15647ca0dd309c96
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Tue Dec 12 15:13:12 2023 -0300
CAMEL-20206: split overly complex method in CamelInternalProcessor (#12426)
---
.../camel/impl/engine/CamelInternalProcessor.java | 56 ++++++++++++----------
1 file changed, 30 insertions(+), 26 deletions(-)
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
index b98243a96b2..48c3b610da9 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
@@ -653,32 +653,7 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor implements In
true, false, backlogTracer.incrementTraceCounter(), created, source, routeId, null, exchangeId,
rest, template, messageAsXml, messageAsJSon);
backlogTracer.traceEvent(pseudoFirst);
- exchange.getExchangeExtension().addOnCompletion(new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- // create pseudo last
- String routeId = routeDefinition != null ? routeDefinition.getRouteId() : null;
- String exchangeId = exchange.getExchangeId();
- boolean includeExchangeProperties = backlogTracer.isIncludeExchangeProperties();
- long created = exchange.getCreated();
- String messageAsXml = MessageHelper.dumpAsXml(exchange.getIn(), includeExchangeProperties, true, 4,
- true, backlogTracer.isBodyIncludeStreams(), backlogTracer.isBodyIncludeFiles(),
- backlogTracer.getBodyMaxChars());
- String messageAsJSon
- = MessageHelper.dumpAsJSon(exchange.getIn(), includeExchangeProperties, true, 4,
- true, backlogTracer.isBodyIncludeStreams(), backlogTracer.isBodyIncludeFiles(),
- backlogTracer.getBodyMaxChars(), true);
- DefaultBacklogTracerEventMessage pseudoLast = new DefaultBacklogTracerEventMessage(
- false, true, backlogTracer.incrementTraceCounter(), created, source, routeId, null,
- exchangeId, rest, template, messageAsXml, messageAsJSon);
- backlogTracer.traceEvent(pseudoLast);
- doneProcessing(exchange, pseudoLast);
- doneProcessing(exchange, pseudoFirst);
- // to not be confused then lets store duration on first/last as (first = 0, last = total time to process)
- pseudoLast.setElapsed(pseudoFirst.getElapsed());
- pseudoFirst.setElapsed(0);
- }
- });
+ exchange.getExchangeExtension().addOnCompletion(createOnCompletion(source, pseudoFirst));
}
String source = LoggerHelper.getLineNumberLoggerName(processorDefinition);
DefaultBacklogTracerEventMessage event = new DefaultBacklogTracerEventMessage(
@@ -692,6 +667,35 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor implements In
return null;
}
+ private SynchronizationAdapter createOnCompletion(String source, DefaultBacklogTracerEventMessage pseudoFirst) {
+ return new SynchronizationAdapter() {
+ @Override
+ public void onDone(Exchange exchange) {
+ // create pseudo last
+ String routeId = routeDefinition != null ? routeDefinition.getRouteId() : null;
+ String exchangeId = exchange.getExchangeId();
+ boolean includeExchangeProperties = backlogTracer.isIncludeExchangeProperties();
+ long created = exchange.getCreated();
+ String messageAsXml = MessageHelper.dumpAsXml(exchange.getIn(), includeExchangeProperties, true, 4,
+ true, backlogTracer.isBodyIncludeStreams(), backlogTracer.isBodyIncludeFiles(),
+ backlogTracer.getBodyMaxChars());
+ String messageAsJSon
+ = MessageHelper.dumpAsJSon(exchange.getIn(), includeExchangeProperties, true, 4,
+ true, backlogTracer.isBodyIncludeStreams(), backlogTracer.isBodyIncludeFiles(),
+ backlogTracer.getBodyMaxChars(), true);
+ DefaultBacklogTracerEventMessage pseudoLast = new DefaultBacklogTracerEventMessage(
+ false, true, backlogTracer.incrementTraceCounter(), created, source, routeId, null,
+ exchangeId, rest, template, messageAsXml, messageAsJSon);
+ backlogTracer.traceEvent(pseudoLast);
+ doneProcessing(exchange, pseudoLast);
+ doneProcessing(exchange, pseudoFirst);
+ // to not be confused then lets store duration on first/last as (first = 0, last = total time to process)
+ pseudoLast.setElapsed(pseudoFirst.getElapsed());
+ pseudoFirst.setElapsed(0);
+ }
+ };
+ }
+
@Override
public void after(Exchange exchange, DefaultBacklogTracerEventMessage data) throws Exception {
if (data != null) {