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

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

commit 5fc2d2f5503b157ecc2409347831fde59ac8aa14
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Jan 28 17:14:55 2020 +0100

    CAMEL-14354: camel-core optimize
---
 .../java/org/apache/camel/processor/Pipeline.java  |  5 +++-
 .../org/apache/camel/processor/SendProcessor.java  | 29 +++++++++++-----------
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git 
a/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java 
b/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java
index 5ecce94..f1a0b53 100644
--- a/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java
+++ b/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java
@@ -109,7 +109,10 @@ public class Pipeline extends AsyncProcessorSupport 
implements Navigate<Processo
         if (!stop && more && (first || continueProcessing(exchange, "so 
breaking out of pipeline", LOG))) {
 
             // prepare for next run
-            ExchangeHelper.prepareOutToIn(exchange);
+            if (exchange.hasOut()) {
+                exchange.setIn(exchange.getOut());
+                exchange.setOut(null);
+            }
 
             // get the next processor
             AsyncProcessor processor = processors.get(index.getAndIncrement());
diff --git 
a/core/camel-base/src/main/java/org/apache/camel/processor/SendProcessor.java 
b/core/camel-base/src/main/java/org/apache/camel/processor/SendProcessor.java
index 5f35371..ab7e5bb 100644
--- 
a/core/camel-base/src/main/java/org/apache/camel/processor/SendProcessor.java
+++ 
b/core/camel-base/src/main/java/org/apache/camel/processor/SendProcessor.java
@@ -32,7 +32,6 @@ import org.apache.camel.spi.IdAware;
 import org.apache.camel.spi.ProducerCache;
 import org.apache.camel.spi.RouteIdAware;
 import org.apache.camel.support.AsyncProcessorSupport;
-import org.apache.camel.support.DefaultConsumer;
 import org.apache.camel.support.EndpointHelper;
 import org.apache.camel.support.EventHelper;
 import org.apache.camel.support.service.ServiceHelper;
@@ -134,7 +133,13 @@ public class SendProcessor extends AsyncProcessorSupport 
implements Traceable, E
         // if we have a producer then use that as its optimized
         if (producer != null) {
 
-            final Exchange target = configureExchange(exchange, pattern);
+            final Exchange target = exchange;
+            // we can send with a different MEP pattern
+            if (destinationExchangePattern != null || pattern != null) {
+                target.setPattern(destinationExchangePattern != null ? 
destinationExchangePattern : pattern);
+            }
+            // set property which endpoint we send to
+            target.setProperty(Exchange.TO_ENDPOINT, 
destination.getEndpointUri());
 
             final boolean sending = 
camelContext.isEventNotificationApplicable() && 
EventHelper.notifyExchangeSending(exchange.getContext(), target, destination);
             // record timing for sending the exchange using the producer
@@ -173,7 +178,13 @@ public class SendProcessor extends AsyncProcessorSupport 
implements Traceable, E
 
             return true;
         } else {
-            configureExchange(exchange, pattern);
+            // we can send with a different MEP pattern
+            if (destinationExchangePattern != null || pattern != null) {
+                exchange.setPattern(destinationExchangePattern != null ? 
destinationExchangePattern : pattern);
+            }
+            // set property which endpoint we send to
+            exchange.setProperty(Exchange.TO_ENDPOINT, 
destination.getEndpointUri());
+
             LOG.debug(">>>> {} {}", destination, exchange);
 
             // send the exchange to the destination using the producer cache 
for the non optimized producers
@@ -194,18 +205,6 @@ public class SendProcessor extends AsyncProcessorSupport 
implements Traceable, E
         return pattern;
     }
 
-    protected Exchange configureExchange(Exchange exchange, ExchangePattern 
pattern) {
-        // destination exchange pattern overrides pattern
-        if (destinationExchangePattern != null) {
-            exchange.setPattern(destinationExchangePattern);
-        } else if (pattern != null) {
-            exchange.setPattern(pattern);
-        }
-        // set property which endpoint we send to
-        exchange.setProperty(Exchange.TO_ENDPOINT, 
destination.getEndpointUri());
-        return exchange;
-    }
-
     public long getCounter() {
         return counter;
     }

Reply via email to