You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/01/20 15:29:05 UTC

[camel] branch master updated (0c05eba -> 60f78f5)

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

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


    from 0c05eba  Support subscriptionInitialPosition in camel-pulsar
     new d7952e5  CAMEL-14354: Optimize core
     new 37252db  CAMEL-14418: camel-timer - Add option to turn on/off metadata
     new c41fc98  Polished
     new 5845e5d  CAMEL-14419: Enrich EIP - Should wrap in UoW
     new c8e37b1  CAMEL-14419: Enrich EIP - Should wrap in UoW
     new 60f78f5  CAMEL-14354: Optimize core

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ...InterceptUsingAdviceWithSendToEndpointTest.java |  2 +-
 .../camel-timer/src/main/docs/timer-component.adoc |  3 +-
 .../camel/component/timer/TimerConsumer.java       | 21 +++++++------
 .../camel/component/timer/TimerEndpoint.java       | 16 ++++++++++
 .../main/java/org/apache/camel/spi/UnitOfWork.java | 13 +++++++--
 .../camel/impl/engine/DefaultUnitOfWork.java       |  6 ++++
 .../apache/camel/impl/engine/MDCUnitOfWork.java    |  5 ++++
 .../camel/processor/CamelInternalProcessor.java    | 34 +++++++++++++---------
 .../java/org/apache/camel/processor/Enricher.java  |  4 ++-
 .../processor/SharedCamelInternalProcessor.java    | 34 ++++++++++++----------
 .../org/apache/camel/reifier/EnrichReifier.java    |  2 +-
 .../apache/camel/reifier/RecipientListReifier.java |  7 +----
 .../camel/impl/CustomUnitOfWorkFactoryTest.java    |  5 ++++
 .../endpoint/dsl/TimerEndpointBuilderFactory.java  | 26 +++++++++++++++++
 .../modules/ROOT/pages/camel-3x-upgrade-guide.adoc |  5 ++++
 15 files changed, 133 insertions(+), 50 deletions(-)


[camel] 02/06: CAMEL-14418: camel-timer - Add option to turn on/off metadata

Posted by da...@apache.org.
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 37252db0e679c56b96d4027122592f50ff05f332
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jan 20 13:54:59 2020 +0100

    CAMEL-14418: camel-timer - Add option to turn on/off metadata
---
 .../camel-timer/src/main/docs/timer-component.adoc |  3 ++-
 .../camel/component/timer/TimerConsumer.java       | 21 +++++++++--------
 .../camel/component/timer/TimerEndpoint.java       | 16 +++++++++++++
 .../endpoint/dsl/TimerEndpointBuilderFactory.java  | 26 ++++++++++++++++++++++
 4 files changed, 56 insertions(+), 10 deletions(-)

diff --git a/components/camel-timer/src/main/docs/timer-component.adoc b/components/camel-timer/src/main/docs/timer-component.adoc
index 67331c0..6d0ba5a 100644
--- a/components/camel-timer/src/main/docs/timer-component.adoc
+++ b/components/camel-timer/src/main/docs/timer-component.adoc
@@ -80,7 +80,7 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (13 parameters):
+=== Query Parameters (14 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -89,6 +89,7 @@ with the following path and query parameters:
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
 | *delay* (consumer) | The number of milliseconds to wait before the first event is generated. Should not be used in conjunction with the time option. The default value is 1000. You can also specify time values using units, such as 60s (60 seconds), 5m30s (5 minutes and 30 seconds), and 1h (1 hour). | 1000 | long
 | *fixedRate* (consumer) | Events take place at approximately regular intervals, separated by the specified period. | false | boolean
+| *includeMetadata* (consumer) | Whether to include metadata in the exchange such as fired time, timer name, timer count etc. This information is default included. | true | boolean
 | *period* (consumer) | If greater than 0, generate periodic events every period milliseconds. The default value is 1000. You can also specify time values using units, such as 60s (60 seconds), 5m30s (5 minutes and 30 seconds), and 1h (1 hour). | 1000 | long
 | *repeatCount* (consumer) | Specifies a maximum limit of number of fires. So if you set it to 1, the timer will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever. | 0 | long
 | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
diff --git a/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerConsumer.java b/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
index 695ad11..5170dd9 100644
--- a/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
+++ b/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
@@ -175,15 +175,18 @@ public class TimerConsumer extends DefaultConsumer implements StartupListener, S
 
     protected void sendTimerExchange(long counter) {
         final Exchange exchange = endpoint.createExchange();
-        exchange.setProperty(Exchange.TIMER_COUNTER, counter);
-        exchange.setProperty(Exchange.TIMER_NAME, endpoint.getTimerName());
-        exchange.setProperty(Exchange.TIMER_TIME, endpoint.getTime());
-        exchange.setProperty(Exchange.TIMER_PERIOD, endpoint.getPeriod());
-
-        Date now = new Date();
-        exchange.setProperty(Exchange.TIMER_FIRED_TIME, now);
-        // also set now on in header with same key as quartz to be consistent
-        exchange.getIn().setHeader("firedTime", now);
+
+        if (endpoint.isIncludeMetadata()) {
+            exchange.setProperty(Exchange.TIMER_COUNTER, counter);
+            exchange.setProperty(Exchange.TIMER_NAME, endpoint.getTimerName());
+            exchange.setProperty(Exchange.TIMER_TIME, endpoint.getTime());
+            exchange.setProperty(Exchange.TIMER_PERIOD, endpoint.getPeriod());
+
+            Date now = new Date();
+            exchange.setProperty(Exchange.TIMER_FIRED_TIME, now);
+            // also set now on in header with same key as quartz to be consistent
+            exchange.getIn().setHeader("firedTime", now);
+        }
 
         if (log.isTraceEnabled()) {
             log.trace("Timer {} is firing #{} count", endpoint.getTimerName(), counter);
diff --git a/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java b/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java
index 8cc57f8..e1d9490 100644
--- a/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java
+++ b/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java
@@ -61,6 +61,8 @@ public class TimerEndpoint extends DefaultEndpoint implements MultipleConsumersS
     private String pattern;
     @UriParam(label = "advanced")
     private Timer timer;
+    @UriParam(defaultValue = "true")
+    private boolean includeMetadata = true;
 
     public TimerEndpoint() {
     }
@@ -244,6 +246,20 @@ public class TimerEndpoint extends DefaultEndpoint implements MultipleConsumersS
         return getComponent().getTimer(consumer);
     }
 
+    @ManagedAttribute(description = "Include metadata")
+    public boolean isIncludeMetadata() {
+        return includeMetadata;
+    }
+
+    /**
+     * Whether to include metadata in the exchange such as fired time, timer name, timer count etc.
+     * This information is default included.
+     */
+    @ManagedAttribute(description = "Include metadata")
+    public void setIncludeMetadata(boolean includeMetadata) {
+        this.includeMetadata = includeMetadata;
+    }
+
     public void removeTimer(TimerConsumer consumer) {
         if (timer == null) {
             // only remove timer if we are not using a custom timer
diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/TimerEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/TimerEndpointBuilderFactory.java
index c409216..373a5c6 100644
--- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/TimerEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/TimerEndpointBuilderFactory.java
@@ -139,6 +139,32 @@ public interface TimerEndpointBuilderFactory {
             return this;
         }
         /**
+         * Whether to include metadata in the exchange such as fired time, timer
+         * name, timer count etc. This information is default included.
+         * 
+         * The option is a: <code>boolean</code> type.
+         * 
+         * Default: true
+         * Group: consumer
+         */
+        default TimerEndpointBuilder includeMetadata(boolean includeMetadata) {
+            doSetProperty("includeMetadata", includeMetadata);
+            return this;
+        }
+        /**
+         * Whether to include metadata in the exchange such as fired time, timer
+         * name, timer count etc. This information is default included.
+         * 
+         * The option will be converted to a <code>boolean</code> type.
+         * 
+         * Default: true
+         * Group: consumer
+         */
+        default TimerEndpointBuilder includeMetadata(String includeMetadata) {
+            doSetProperty("includeMetadata", includeMetadata);
+            return this;
+        }
+        /**
          * If greater than 0, generate periodic events every period
          * milliseconds. The default value is 1000. You can also specify time
          * values using units, such as 60s (60 seconds), 5m30s (5 minutes and 30


[camel] 03/06: Polished

Posted by da...@apache.org.
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 c41fc982d0f77cf239ea46346304ab15e3bc7d5e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jan 20 14:55:43 2020 +0100

    Polished
---
 .../main/java/org/apache/camel/reifier/RecipientListReifier.java   | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RecipientListReifier.java b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RecipientListReifier.java
index a2fe5d2..6d9a566 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RecipientListReifier.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RecipientListReifier.java
@@ -109,12 +109,7 @@ public class RecipientListReifier extends ProcessorReifier<RecipientListDefiniti
 
         // wrap in nested pipeline so this appears as one processor
         // (threads definition does this as well)
-        return new Pipeline(routeContext.getCamelContext(), pipe) {
-            @Override
-            public String toString() {
-                return "RecipientList[" + expression + "]";
-            }
-        };
+        return new Pipeline(routeContext.getCamelContext(), pipe);
     }
 
     private AggregationStrategy createAggregationStrategy(RouteContext routeContext) {


[camel] 01/06: CAMEL-14354: Optimize core

Posted by da...@apache.org.
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 d7952e5b2be84b94b78e414dc6477e3d8167e678
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Jan 19 22:36:32 2020 +0100

    CAMEL-14354: Optimize core
---
 .../main/java/org/apache/camel/spi/UnitOfWork.java | 13 +++++++--
 .../camel/impl/engine/DefaultUnitOfWork.java       |  6 ++++
 .../apache/camel/impl/engine/MDCUnitOfWork.java    |  5 ++++
 .../camel/processor/CamelInternalProcessor.java    | 34 +++++++++++++---------
 .../processor/SharedCamelInternalProcessor.java    | 34 ++++++++++++----------
 .../camel/impl/CustomUnitOfWorkFactoryTest.java    |  5 ++++
 6 files changed, 66 insertions(+), 31 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java b/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java
index 42bac62..e7efd1e 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java
@@ -188,11 +188,18 @@ public interface UnitOfWork extends Service {
     RouteContext popRouteContext();
 
     /**
-     * Strategy for optional work to be execute before processing
+     * Whether the unit of work should call the before/after process methods or not.
+     */
+    boolean isBeforeAfterProcess();
+
+    /**
+     * Strategy for work to be execute before processing.
      * <p/>
      * For example the MDCUnitOfWork leverages this
      * to ensure MDC is handled correctly during routing exchanges using the
      * asynchronous routing engine.
+     * <p/>
+     * This requires {@link #isBeforeAfterProcess()} returns <tt>true</tt> to be enabled.
      *
      * @param processor the processor to be executed
      * @param exchange  the current exchange
@@ -202,7 +209,9 @@ public interface UnitOfWork extends Service {
     AsyncCallback beforeProcess(Processor processor, Exchange exchange, AsyncCallback callback);
 
     /**
-     * Strategy for optional work to be executed after the processing
+     * Strategy for work to be executed after the processing
+     * <p/>
+     * This requires {@link #isBeforeAfterProcess()} returns <tt>true</tt> to be enabled.
      *
      * @param processor the processor executed
      * @param exchange  the current exchange
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
index a96df0b..42e70fd 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
@@ -292,6 +292,11 @@ public class DefaultUnitOfWork implements UnitOfWork, Service {
     }
 
     @Override
+    public boolean isBeforeAfterProcess() {
+        return false;
+    }
+
+    @Override
     public AsyncCallback beforeProcess(Processor processor, Exchange exchange, AsyncCallback callback) {
         // no wrapping needed
         return callback;
@@ -299,6 +304,7 @@ public class DefaultUnitOfWork implements UnitOfWork, Service {
 
     @Override
     public void afterProcess(Processor processor, Exchange exchange, AsyncCallback callback, boolean doneSync) {
+        // noop
     }
 
     private Set<Object> getTransactedBy() {
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/MDCUnitOfWork.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/MDCUnitOfWork.java
index 30812db..006f579 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/MDCUnitOfWork.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/MDCUnitOfWork.java
@@ -127,6 +127,11 @@ public class MDCUnitOfWork extends DefaultUnitOfWork {
     }
 
     @Override
+    public boolean isBeforeAfterProcess() {
+        return true;
+    }
+
+    @Override
     public AsyncCallback beforeProcess(Processor processor, Exchange exchange, AsyncCallback callback) {
         // add optional step id
         String stepId = exchange.getProperty(Exchange.STEP_ID, String.class);
diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java b/core/camel-base/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java
index 9c9164f..46cc50e 100644
--- a/core/camel-base/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java
+++ b/core/camel-base/src/main/java/org/apache/camel/processor/CamelInternalProcessor.java
@@ -134,6 +134,7 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor {
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     public boolean process(Exchange exchange, AsyncCallback originalCallback) {
         // ----------------------------------------------------------
         // CAMEL END USER - READ ME FOR DEBUGGING TIPS
@@ -193,7 +194,9 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor {
                 // CAMEL END USER - DEBUG ME HERE +++ START +++
                 // ----------------------------------------------------------
                 // callback must be called
-                exchange.getContext().getReactiveExecutor().schedule(originalCallback);
+                if (originalCallback != null) {
+                    exchange.getContext().getReactiveExecutor().schedule(originalCallback);
+                }
                 // ----------------------------------------------------------
                 // CAMEL END USER - DEBUG ME HERE +++ END +++
                 // ----------------------------------------------------------
@@ -225,11 +228,12 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor {
         } else {
             final UnitOfWork uow = exchange.getUnitOfWork();
 
-            // allow unit of work to wrap callback in case it need to do some special work
-            // for example the MDCUnitOfWork
+            // do uow before processing and if a value is returned the the uow wants to be processed after
+            // was well in the same thread
             AsyncCallback async = callback;
-            if (uow != null) {
-                async = uow.beforeProcess(processor, exchange, callback);
+            boolean beforeAndAfter = uow.isBeforeAfterProcess();
+            if (beforeAndAfter) {
+                async = uow.beforeProcess(processor, exchange, async);
             }
 
             // ----------------------------------------------------------
@@ -243,17 +247,19 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor {
             // CAMEL END USER - DEBUG ME HERE +++ END +++
             // ----------------------------------------------------------
 
-            exchange.getContext().getReactiveExecutor().schedule(() -> {
-                // execute any after processor work (in current thread, not in the callback)
-                if (uow != null) {
+            // optimize to only do after uow processing if really needed
+            if (beforeAndAfter) {
+                exchange.getContext().getReactiveExecutor().schedule(() -> {
+                    // execute any after processor work (in current thread, not in the callback)
                     uow.afterProcess(processor, exchange, callback, false);
-                }
+                });
+            }
 
-                if (log.isTraceEnabled()) {
-                    log.trace("Exchange processed and is continued routed asynchronously for exchangeId: {} -> {}",
-                             exchange.getExchangeId(), exchange);
-                }
-            });
+            if (log.isTraceEnabled()) {
+                log.trace("Exchange processed and is continued routed asynchronously for exchangeId: {} -> {}",
+                        exchange.getExchangeId(), exchange);
+            }
+            // must return false
             return false;
         }
     }
diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/SharedCamelInternalProcessor.java b/core/camel-base/src/main/java/org/apache/camel/processor/SharedCamelInternalProcessor.java
index 61f3177..687b875b 100644
--- a/core/camel-base/src/main/java/org/apache/camel/processor/SharedCamelInternalProcessor.java
+++ b/core/camel-base/src/main/java/org/apache/camel/processor/SharedCamelInternalProcessor.java
@@ -185,11 +185,12 @@ public class SharedCamelInternalProcessor {
         } else {
             final UnitOfWork uow = exchange.getUnitOfWork();
 
-            // allow unit of work to wrap callback in case it need to do some special work
-            // for example the MDCUnitOfWork
+            // do uow before processing and if a value is returned the the uow wants to be processed after
+            // was well in the same thread
             AsyncCallback async = callback;
-            if (uow != null) {
-                async = uow.beforeProcess(processor, exchange, callback);
+            boolean beforeAndAfter = uow.isBeforeAfterProcess();
+            if (beforeAndAfter) {
+                async = uow.beforeProcess(processor, exchange, async);
             }
 
             // ----------------------------------------------------------
@@ -203,17 +204,18 @@ public class SharedCamelInternalProcessor {
             // CAMEL END USER - DEBUG ME HERE +++ END +++
             // ----------------------------------------------------------
 
-            exchange.getContext().getReactiveExecutor().schedule(() -> {
-                // execute any after processor work (in current thread, not in the callback)
-                if (uow != null) {
+            // optimize to only do after uow processing if really needed
+            if (beforeAndAfter) {
+                exchange.getContext().getReactiveExecutor().schedule(() -> {
+                    // execute any after processor work (in current thread, not in the callback)
                     uow.afterProcess(processor, exchange, callback, sync);
-                }
+                });
+            }
 
-                if (LOG.isTraceEnabled()) {
-                    LOG.trace("Exchange processed and is continued routed asynchronously for exchangeId: {} -> {}",
-                            exchange.getExchangeId(), exchange);
-                }
-            });
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Exchange processed and is continued routed asynchronously for exchangeId: {} -> {}",
+                        exchange.getExchangeId(), exchange);
+            }
             return sync;
         }
     }
@@ -251,7 +253,7 @@ public class SharedCamelInternalProcessor {
 
             // we should call after in reverse order
             try {
-                for (int i = advices.size() - 1, j = states.length - 1; i >= 0; i--) {
+                for (int i = advices != null ? advices.size() - 1 : -1, j = states.length - 1; i >= 0; i--) {
                     CamelInternalProcessorAdvice task = advices.get(i);
                     Object state = null;
                     if (task.hasState()) {
@@ -269,7 +271,9 @@ public class SharedCamelInternalProcessor {
                 // CAMEL END USER - DEBUG ME HERE +++ START +++
                 // ----------------------------------------------------------
                 // callback must be called
-                exchange.getContext().getReactiveExecutor().schedule(callback);
+                if (callback != null) {
+                    exchange.getContext().getReactiveExecutor().schedule(callback);
+                }
                 // ----------------------------------------------------------
                 // CAMEL END USER - DEBUG ME HERE +++ END +++
                 // ----------------------------------------------------------
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/CustomUnitOfWorkFactoryTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/CustomUnitOfWorkFactoryTest.java
index ffdca8f..b4e9776 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/CustomUnitOfWorkFactoryTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/CustomUnitOfWorkFactoryTest.java
@@ -76,5 +76,10 @@ public class CustomUnitOfWorkFactoryTest extends ContextTestSupport {
             exchange.getIn().setHeader("before", "I was here");
             return callback;
         }
+
+        @Override
+        public boolean isBeforeAfterProcess() {
+            return true;
+        }
     }
 }


[camel] 04/06: CAMEL-14419: Enrich EIP - Should wrap in UoW

Posted by da...@apache.org.
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 5845e5de2d72844f62c52ba9ced9e6ffb44c6499
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jan 20 15:15:02 2020 +0100

    CAMEL-14419: Enrich EIP - Should wrap in UoW
---
 .../TransactedInterceptUsingAdviceWithSendToEndpointTest.java     | 2 +-
 .../src/main/java/org/apache/camel/processor/Enricher.java        | 4 +++-
 .../src/main/java/org/apache/camel/reifier/EnrichReifier.java     | 8 +++++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactedInterceptUsingAdviceWithSendToEndpointTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactedInterceptUsingAdviceWithSendToEndpointTest.java
index 47e4579..46a3248 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactedInterceptUsingAdviceWithSendToEndpointTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactedInterceptUsingAdviceWithSendToEndpointTest.java
@@ -56,7 +56,7 @@ public class TransactedInterceptUsingAdviceWithSendToEndpointTest extends Transa
     }
     
     private void addInterceptor(String routeId) throws Exception {
-        RouteReifier.adviceWith(context.getRouteDefinitions().get(0), context, new AdviceWithRouteBuilder() {
+        RouteReifier.adviceWith(context.getRouteDefinition(routeId), context, new AdviceWithRouteBuilder() {
             @Override
             public void configure() throws Exception {
                 interceptSendToEndpoint("direct:(foo|bar)")
diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/Enricher.java b/core/camel-base/src/main/java/org/apache/camel/processor/Enricher.java
index 411b36a..f484d0a 100644
--- a/core/camel-base/src/main/java/org/apache/camel/processor/Enricher.java
+++ b/core/camel-base/src/main/java/org/apache/camel/processor/Enricher.java
@@ -197,7 +197,9 @@ public class Enricher extends AsyncProcessorSupport implements IdAware, RouteIdA
         }
         // record timing for sending the exchange using the producer
         final StopWatch watch = sw;
-        AsyncProcessor ap = AsyncProcessorConverterHelper.convert(producer);
+        // make sure to wrap producer in unit of work
+        AsyncProcessor ap = AsyncProcessorConverterHelper.convert(new UnitOfWorkProducer(producer));
+        // wrap in UoW
         boolean sync = ap.process(resourceExchange, new AsyncCallback() {
             public void done(boolean doneSync) {
                 // we only have to handle async completion of the routing slip
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/EnrichReifier.java b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/EnrichReifier.java
index 98f4bc4..bd58305 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/EnrichReifier.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/EnrichReifier.java
@@ -22,6 +22,7 @@ import org.apache.camel.Expression;
 import org.apache.camel.Processor;
 import org.apache.camel.model.EnrichDefinition;
 import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.processor.CamelInternalProcessor;
 import org.apache.camel.processor.Enricher;
 import org.apache.camel.processor.aggregate.AggregationStrategyBeanAdapter;
 import org.apache.camel.spi.RouteContext;
@@ -34,7 +35,6 @@ public class EnrichReifier extends ExpressionReifier<EnrichDefinition> {
 
     @Override
     public Processor createProcessor(RouteContext routeContext) throws Exception {
-
         Expression exp = definition.getExpression().createExpression(routeContext);
         boolean isShareUnitOfWork = definition.getShareUnitOfWork() != null && Boolean.parseBoolean(definition.getShareUnitOfWork());
         boolean isIgnoreInvalidEndpoint = definition.getIgnoreInvalidEndpoint() != null && Boolean.parseBoolean(definition.getIgnoreInvalidEndpoint());
@@ -49,7 +49,13 @@ public class EnrichReifier extends ExpressionReifier<EnrichDefinition> {
         if (definition.getAggregateOnException() != null) {
             enricher.setAggregateOnException(Boolean.parseBoolean(definition.getAggregateOnException()));
         }
+
         return enricher;
+
+        // and wrap in unit of work
+//        CamelInternalProcessor internal = new CamelInternalProcessor(enricher);
+//        internal.addAdvice(new CamelInternalProcessor.UnitOfWorkProcessorAdvice(routeContext));
+//        return internal;
     }
 
     private AggregationStrategy createAggregationStrategy(RouteContext routeContext) {


[camel] 05/06: CAMEL-14419: Enrich EIP - Should wrap in UoW

Posted by da...@apache.org.
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 c8e37b117e2d16e074c2f8a4092d53647ca7a6d3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jan 20 16:03:37 2020 +0100

    CAMEL-14419: Enrich EIP - Should wrap in UoW
---
 .../src/main/java/org/apache/camel/reifier/EnrichReifier.java       | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/EnrichReifier.java b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/EnrichReifier.java
index bd58305..f72cfd7 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/EnrichReifier.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/EnrichReifier.java
@@ -22,7 +22,6 @@ import org.apache.camel.Expression;
 import org.apache.camel.Processor;
 import org.apache.camel.model.EnrichDefinition;
 import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.processor.CamelInternalProcessor;
 import org.apache.camel.processor.Enricher;
 import org.apache.camel.processor.aggregate.AggregationStrategyBeanAdapter;
 import org.apache.camel.spi.RouteContext;
@@ -51,11 +50,6 @@ public class EnrichReifier extends ExpressionReifier<EnrichDefinition> {
         }
 
         return enricher;
-
-        // and wrap in unit of work
-//        CamelInternalProcessor internal = new CamelInternalProcessor(enricher);
-//        internal.addAdvice(new CamelInternalProcessor.UnitOfWorkProcessorAdvice(routeContext));
-//        return internal;
     }
 
     private AggregationStrategy createAggregationStrategy(RouteContext routeContext) {


[camel] 06/06: CAMEL-14354: Optimize core

Posted by da...@apache.org.
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 60f78f51e06f776ea051b5c5d5b8faeedd0794f2
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jan 20 16:03:48 2020 +0100

    CAMEL-14354: Optimize core
---
 docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
index acec046..2c8eb66 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
@@ -131,6 +131,11 @@ You can use these methods by adapting to the extended exchange as shown below:
 exchange.adapt(ExtendedExchange.class).addOnCompletion(...);
 ----
 
+==== UnitOfWork
+
+For advanced Camel users whom implement custom `UnitOfWork` should implement the new `isBeforeAfterProcess()' method and return true of false,
+whether Camel should invoke the before and after processor methods.
+
 ==== Cookies
 
 Cookies from `camel-http-common` has been moved into a new `camel-http-base` JAR.