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 2023/12/13 12:15:07 UTC

(camel) branch main updated: CAMEL-20230: camel-core - PollEnrich and Enrich EIP should eager start component if possible (#12441)

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 72ddd49933f CAMEL-20230: camel-core - PollEnrich and Enrich EIP should eager start component if possible (#12441)
72ddd49933f is described below

commit 72ddd49933f713ad35e437fafbe8a1973f0de9d3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 13 13:15:00 2023 +0100

    CAMEL-20230: camel-core - PollEnrich and Enrich EIP should eager start component if possible (#12441)
---
 .../org/apache/camel/catalog/models/enrich.json    |  3 +-
 .../apache/camel/catalog/models/pollEnrich.json    |  3 +-
 .../apache/camel/catalog/schemas/camel-spring.xsd  | 18 ++++++++++
 .../java/org/apache/camel/spi/ClassResolver.java   |  4 +--
 .../resources/org/apache/camel/model/enrich.json   |  3 +-
 .../org/apache/camel/model/pollEnrich.json         |  3 +-
 .../org/apache/camel/model/EnrichDefinition.java   | 20 +++++++++++
 .../apache/camel/model/PollEnrichDefinition.java   | 21 +++++++++++
 .../java/org/apache/camel/processor/Enricher.java  | 16 +++++++--
 .../org/apache/camel/processor/PollEnricher.java   | 41 +++++++++++++++++-----
 .../org/apache/camel/reifier/EnrichReifier.java    | 20 +++++++++--
 .../apache/camel/reifier/PollEnrichReifier.java    | 10 ++++--
 .../org/apache/camel/reifier/ToDynamicReifier.java |  2 +-
 .../java/org/apache/camel/xml/in/ModelParser.java  |  2 ++
 .../java/org/apache/camel/xml/out/ModelWriter.java |  2 ++
 .../org/apache/camel/yaml/out/ModelWriter.java     |  2 ++
 .../dsl/yaml/deserializers/ModelDeserializers.java | 12 +++++++
 .../generated/resources/schema/camelYamlDsl.json   | 10 ++++++
 18 files changed, 170 insertions(+), 22 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/enrich.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/enrich.json
index 6e0517b3645..7326f89b55c 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/enrich.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/enrich.json
@@ -23,6 +23,7 @@
     "shareUnitOfWork": { "index": 8, "kind": "attribute", "displayName": "Share Unit Of Work", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Shares the org.apache.camel.spi.UnitOfWork with the parent and the resource exchange. Enrich will by default not share unit of work between the parent exchange and the resource exchange. This means the resour [...]
     "cacheSize": { "index": 9, "kind": "attribute", "displayName": "Cache Size", "label": "advanced", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producer when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic end [...]
     "ignoreInvalidEndpoint": { "index": 10, "kind": "attribute", "displayName": "Ignore Invalid Endpoint", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Ignore the invalidate endpoint exception when try to create a producer with that endpoint" },
-    "allowOptimisedComponents": { "index": 11, "kind": "attribute", "displayName": "Allow Optimised Components", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow components to optimise enricher if they are org.apache.camel.spi.SendDynamicAware ." }
+    "allowOptimisedComponents": { "index": 11, "kind": "attribute", "displayName": "Allow Optimised Components", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow components to optimise enricher if they are org.apache.camel.spi.SendDynamicAware ." },
+    "autoStartComponents": { "index": 12, "kind": "attribute", "displayName": "Auto Start Components", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to auto startup components when enricher is starting up." }
   }
 }
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json
index 371dc7abfef..e3ec0d66eb8 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json
@@ -22,6 +22,7 @@
     "aggregateOnException": { "index": 7, "kind": "attribute", "displayName": "Aggregate On Exception", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If this option is false then the aggregate method is not used if there was an exception thrown while trying to retrieve the data to enrich from the resource. Setting this option to true allows end us [...]
     "timeout": { "index": 8, "kind": "attribute", "displayName": "Timeout", "required": false, "type": "duration", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "-1", "description": "Timeout in millis when polling from the external service. The timeout has influence about the poll enrich behavior. It basically operations in three different modes: negative value - Waits until a message is available and then returns it. Warning th [...]
     "cacheSize": { "index": 9, "kind": "attribute", "displayName": "Cache Size", "label": "advanced", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the maximum size used by the org.apache.camel.spi.ConsumerCache which is used to cache and reuse consumers when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic en [...]
-    "ignoreInvalidEndpoint": { "index": 10, "kind": "attribute", "displayName": "Ignore Invalid Endpoint", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Ignore the invalidate endpoint exception when try to create a producer with that endpoint" }
+    "ignoreInvalidEndpoint": { "index": 10, "kind": "attribute", "displayName": "Ignore Invalid Endpoint", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Ignore the invalidate endpoint exception when try to create a producer with that endpoint" },
+    "autoStartComponents": { "index": 11, "kind": "attribute", "displayName": "Auto Start Components", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to auto startup components when poll enricher is starting up." }
   }
 }
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index f754e021af4..9141b19db6a 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -5250,6 +5250,15 @@ Ignore the invalidate endpoint exception when try to create a producer with that
             <xs:documentation xml:lang="en">
 <![CDATA[
 Whether to allow components to optimise enricher if they are org.apache.camel.spi.SendDynamicAware . Default value: true
+]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:attribute>
+        <xs:attribute name="autoStartComponents" type="xs:string">
+          <xs:annotation>
+            <xs:documentation xml:lang="en">
+<![CDATA[
+Whether to auto startup components when enricher is starting up. Default value: true
 ]]>
             </xs:documentation>
           </xs:annotation>
@@ -11002,6 +11011,15 @@ storing too many non frequent used producers.
             <xs:documentation xml:lang="en">
 <![CDATA[
 Ignore the invalidate endpoint exception when try to create a producer with that endpoint. Default value: false
+]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:attribute>
+        <xs:attribute name="autoStartComponents" type="xs:string">
+          <xs:annotation>
+            <xs:documentation xml:lang="en">
+<![CDATA[
+Whether to auto startup components when poll enricher is starting up. Default value: true
 ]]>
             </xs:documentation>
           </xs:annotation>
diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ClassResolver.java b/core/camel-api/src/main/java/org/apache/camel/spi/ClassResolver.java
index 6eefdf5a808..fa0897d1ab4 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/ClassResolver.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/ClassResolver.java
@@ -42,8 +42,8 @@ public interface ClassResolver {
     /**
      * Gets a custom class loader by its name
      *
-     * @param name the name of the custom classloader
-     * @return the class loader or <tt>null</tt> if not found
+     * @param  name the name of the custom classloader
+     * @return      the class loader or <tt>null</tt> if not found
      */
     ClassLoader getClassLoader(String name);
 
diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/enrich.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/enrich.json
index 6e0517b3645..7326f89b55c 100644
--- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/enrich.json
+++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/enrich.json
@@ -23,6 +23,7 @@
     "shareUnitOfWork": { "index": 8, "kind": "attribute", "displayName": "Share Unit Of Work", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Shares the org.apache.camel.spi.UnitOfWork with the parent and the resource exchange. Enrich will by default not share unit of work between the parent exchange and the resource exchange. This means the resour [...]
     "cacheSize": { "index": 9, "kind": "attribute", "displayName": "Cache Size", "label": "advanced", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producer when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic end [...]
     "ignoreInvalidEndpoint": { "index": 10, "kind": "attribute", "displayName": "Ignore Invalid Endpoint", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Ignore the invalidate endpoint exception when try to create a producer with that endpoint" },
-    "allowOptimisedComponents": { "index": 11, "kind": "attribute", "displayName": "Allow Optimised Components", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow components to optimise enricher if they are org.apache.camel.spi.SendDynamicAware ." }
+    "allowOptimisedComponents": { "index": 11, "kind": "attribute", "displayName": "Allow Optimised Components", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow components to optimise enricher if they are org.apache.camel.spi.SendDynamicAware ." },
+    "autoStartComponents": { "index": 12, "kind": "attribute", "displayName": "Auto Start Components", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to auto startup components when enricher is starting up." }
   }
 }
diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/pollEnrich.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/pollEnrich.json
index 371dc7abfef..e3ec0d66eb8 100644
--- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/pollEnrich.json
+++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/pollEnrich.json
@@ -22,6 +22,7 @@
     "aggregateOnException": { "index": 7, "kind": "attribute", "displayName": "Aggregate On Exception", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If this option is false then the aggregate method is not used if there was an exception thrown while trying to retrieve the data to enrich from the resource. Setting this option to true allows end us [...]
     "timeout": { "index": 8, "kind": "attribute", "displayName": "Timeout", "required": false, "type": "duration", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "-1", "description": "Timeout in millis when polling from the external service. The timeout has influence about the poll enrich behavior. It basically operations in three different modes: negative value - Waits until a message is available and then returns it. Warning th [...]
     "cacheSize": { "index": 9, "kind": "attribute", "displayName": "Cache Size", "label": "advanced", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the maximum size used by the org.apache.camel.spi.ConsumerCache which is used to cache and reuse consumers when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic en [...]
-    "ignoreInvalidEndpoint": { "index": 10, "kind": "attribute", "displayName": "Ignore Invalid Endpoint", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Ignore the invalidate endpoint exception when try to create a producer with that endpoint" }
+    "ignoreInvalidEndpoint": { "index": 10, "kind": "attribute", "displayName": "Ignore Invalid Endpoint", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Ignore the invalidate endpoint exception when try to create a producer with that endpoint" },
+    "autoStartComponents": { "index": 11, "kind": "attribute", "displayName": "Auto Start Components", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to auto startup components when poll enricher is starting up." }
   }
 }
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/EnrichDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/EnrichDefinition.java
index 2055a927498..8f8baa14f2a 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/EnrichDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/EnrichDefinition.java
@@ -63,6 +63,9 @@ public class EnrichDefinition extends ExpressionNode implements AggregationStrat
     @XmlAttribute
     @Metadata(label = "advanced", defaultValue = "true", javaType = "java.lang.Boolean")
     private String allowOptimisedComponents;
+    @XmlAttribute
+    @Metadata(label = "advanced", defaultValue = "true", javaType = "java.lang.Boolean")
+    private String autoStartComponents;
 
     public EnrichDefinition() {
         this(null);
@@ -226,6 +229,16 @@ public class EnrichDefinition extends ExpressionNode implements AggregationStrat
         return this;
     }
 
+    /**
+     * Whether to auto startup components when enricher is starting up.
+     *
+     * @return the builder
+     */
+    public EnrichDefinition autoStartComponents(String autoStartComponents) {
+        setAutoStartComponents(autoStartComponents);
+        return this;
+    }
+
     // Properties
     // -------------------------------------------------------------------------
 
@@ -315,4 +328,11 @@ public class EnrichDefinition extends ExpressionNode implements AggregationStrat
         this.allowOptimisedComponents = allowOptimisedComponents;
     }
 
+    public String getAutoStartComponents() {
+        return autoStartComponents;
+    }
+
+    public void setAutoStartComponents(String autoStartComponents) {
+        this.autoStartComponents = autoStartComponents;
+    }
 }
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/PollEnrichDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/PollEnrichDefinition.java
index 58b8afa117d..b61e9604c68 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/PollEnrichDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/PollEnrichDefinition.java
@@ -60,6 +60,9 @@ public class PollEnrichDefinition extends ExpressionNode implements AggregationS
     @XmlAttribute
     @Metadata(label = "advanced", javaType = "java.lang.Boolean")
     private String ignoreInvalidEndpoint;
+    @XmlAttribute
+    @Metadata(label = "advanced", defaultValue = "true", javaType = "java.lang.Boolean")
+    private String autoStartComponents;
 
     public PollEnrichDefinition() {
     }
@@ -234,6 +237,16 @@ public class PollEnrichDefinition extends ExpressionNode implements AggregationS
         return this;
     }
 
+    /**
+     * Whether to auto startup components when poll enricher is starting up.
+     *
+     * @return the builder
+     */
+    public PollEnrichDefinition autoStartComponents(String autoStartComponents) {
+        setAutoStartComponents(autoStartComponents);
+        return this;
+    }
+
     // Properties
     // -------------------------------------------------------------------------
 
@@ -315,4 +328,12 @@ public class PollEnrichDefinition extends ExpressionNode implements AggregationS
     public void setIgnoreInvalidEndpoint(String ignoreInvalidEndpoint) {
         this.ignoreInvalidEndpoint = ignoreInvalidEndpoint;
     }
+
+    public String getAutoStartComponents() {
+        return autoStartComponents;
+    }
+
+    public void setAutoStartComponents(String autoStartComponents) {
+        this.autoStartComponents = autoStartComponents;
+    }
 }
diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Enricher.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Enricher.java
index 38393021350..d0ac88b9624 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Enricher.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Enricher.java
@@ -53,17 +53,20 @@ public class Enricher extends AsyncProcessorSupport implements IdAware, RouteIdA
     private String id;
     private String routeId;
     private final Expression expression;
+    private final String uri;
     private AggregationStrategy aggregationStrategy;
     private boolean aggregateOnException;
     private boolean shareUnitOfWork;
     private int cacheSize;
     private boolean ignoreInvalidEndpoint;
     private boolean allowOptimisedComponents = true;
+    private boolean autoStartupComponents = true;
     private ProcessorExchangeFactory processorExchangeFactory;
     private SendDynamicProcessor sendDynamicProcessor;
 
-    public Enricher(Expression expression) {
+    public Enricher(Expression expression, String uri) {
         this.expression = expression;
+        this.uri = uri;
     }
 
     @Override
@@ -152,6 +155,14 @@ public class Enricher extends AsyncProcessorSupport implements IdAware, RouteIdA
         this.allowOptimisedComponents = allowOptimisedComponents;
     }
 
+    public boolean isAutoStartupComponents() {
+        return autoStartupComponents;
+    }
+
+    public void setAutoStartupComponents(boolean autoStartupComponents) {
+        this.autoStartupComponents = autoStartupComponents;
+    }
+
     @Override
     public boolean process(final Exchange exchange, final AsyncCallback callback) {
         final Exchange resourceExchange = createResourceExchange(exchange, ExchangePattern.InOut);
@@ -231,11 +242,12 @@ public class Enricher extends AsyncProcessorSupport implements IdAware, RouteIdA
     @Override
     protected void doBuild() throws Exception {
         // use send dynamic to send to endpoint
-        this.sendDynamicProcessor = new SendDynamicProcessor(null, getExpression());
+        this.sendDynamicProcessor = new SendDynamicProcessor(uri, expression);
         this.sendDynamicProcessor.setCamelContext(camelContext);
         this.sendDynamicProcessor.setCacheSize(cacheSize);
         this.sendDynamicProcessor.setIgnoreInvalidEndpoint(ignoreInvalidEndpoint);
         this.sendDynamicProcessor.setAllowOptimisedComponents(allowOptimisedComponents);
+        this.sendDynamicProcessor.setAutoStartupComponents(autoStartupComponents);
 
         // create a per processor exchange factory
         this.processorExchangeFactory = getCamelContext().getCamelContextExtension()
diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/PollEnricher.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/PollEnricher.java
index b820f383017..109266a521b 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/PollEnricher.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/PollEnricher.java
@@ -38,6 +38,7 @@ import org.apache.camel.spi.RouteIdAware;
 import org.apache.camel.support.AsyncProcessorSupport;
 import org.apache.camel.support.BridgeExceptionHandlerToErrorHandler;
 import org.apache.camel.support.DefaultConsumer;
+import org.apache.camel.support.EndpointHelper;
 import org.apache.camel.support.EventDrivenPollingConsumer;
 import org.apache.camel.support.ExchangeHelper;
 import org.apache.camel.support.cache.DefaultConsumerCache;
@@ -63,37 +64,40 @@ public class PollEnricher extends AsyncProcessorSupport implements IdAware, Rout
 
     private CamelContext camelContext;
     private ConsumerCache consumerCache;
+    protected volatile String scheme;
     private String id;
     private String routeId;
     private AggregationStrategy aggregationStrategy;
     private final Expression expression;
-    private final String destination;
+    private final String uri;
     private long timeout;
     private boolean aggregateOnException;
     private int cacheSize;
     private boolean ignoreInvalidEndpoint;
+    private boolean autoStartupComponents = true;
 
     /**
      * Creates a new {@link PollEnricher}.
      *
      * @param expression expression to use to compute the endpoint to poll from.
+     * @param uri        the endpoint to poll from.
      * @param timeout    timeout in millis
      */
-    public PollEnricher(Expression expression, long timeout) {
+    public PollEnricher(Expression expression, String uri, long timeout) {
         this.expression = expression;
-        this.destination = null;
+        this.uri = uri;
         this.timeout = timeout;
     }
 
     /**
      * Creates a new {@link PollEnricher}.
      *
-     * @param destination the endpoint to poll from.
-     * @param timeout     timeout in millis
+     * @param uri     the endpoint to poll from.
+     * @param timeout timeout in millis
      */
-    public PollEnricher(String destination, long timeout) {
+    public PollEnricher(String uri, long timeout) {
         this.expression = null;
-        this.destination = destination;
+        this.uri = uri;
         this.timeout = timeout;
     }
 
@@ -187,6 +191,14 @@ public class PollEnricher extends AsyncProcessorSupport implements IdAware, Rout
         this.ignoreInvalidEndpoint = ignoreInvalidEndpoint;
     }
 
+    public boolean isAutoStartupComponents() {
+        return autoStartupComponents;
+    }
+
+    public void setAutoStartupComponents(boolean autoStartupComponents) {
+        this.autoStartupComponents = autoStartupComponents;
+    }
+
     /**
      * Enriches the input data (<code>exchange</code>) by first obtaining additional data from an endpoint represented
      * by an endpoint <code>producer</code> and second by aggregating input data and additional data. Aggregation of
@@ -214,7 +226,8 @@ public class PollEnricher extends AsyncProcessorSupport implements IdAware, Rout
         Object recipient = null;
         boolean prototype = cacheSize < 0;
         try {
-            recipient = destination != null ? destination : expression.evaluate(exchange, Object.class);
+            // favour using expression to compute the recipient endpoint
+            recipient = expression != null ? expression.evaluate(exchange, Object.class) : uri;
             recipient = prepareRecipient(exchange, recipient);
             Endpoint existing = getExistingEndpoint(camelContext, recipient);
             if (existing == null) {
@@ -437,11 +450,23 @@ public class PollEnricher extends AsyncProcessorSupport implements IdAware, Rout
             expression.init(camelContext);
         }
 
+        if (isAutoStartupComponents() && uri != null) {
+            // in case path has property placeholders then try to let property component resolve those
+            String u = EndpointHelper.resolveEndpointUriPropertyPlaceholders(camelContext, uri);
+            // find out which component it is
+            scheme = ExchangeHelper.resolveScheme(u);
+        }
+
         ServiceHelper.initService(consumerCache, aggregationStrategy);
     }
 
     @Override
     protected void doStart() throws Exception {
+        // ensure the component is started
+        if (autoStartupComponents && scheme != null) {
+            camelContext.getComponent(scheme);
+        }
+
         ServiceHelper.startService(consumerCache, aggregationStrategy);
     }
 
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/EnrichReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/EnrichReifier.java
index f9531b43066..337b99c5c58 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/EnrichReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/EnrichReifier.java
@@ -17,12 +17,15 @@
 package org.apache.camel.reifier;
 
 import org.apache.camel.AggregationStrategy;
+import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
 import org.apache.camel.Route;
 import org.apache.camel.model.EnrichDefinition;
 import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.language.ConstantExpression;
 import org.apache.camel.processor.Enricher;
+import org.apache.camel.support.DefaultExchange;
 
 public class EnrichReifier extends ExpressionReifier<EnrichDefinition> {
 
@@ -32,12 +35,22 @@ public class EnrichReifier extends ExpressionReifier<EnrichDefinition> {
 
     @Override
     public Processor createProcessor() throws Exception {
-        Expression exp = createExpression(definition.getExpression());
         boolean isShareUnitOfWork = parseBoolean(definition.getShareUnitOfWork(), false);
         boolean isIgnoreInvalidEndpoint = parseBoolean(definition.getIgnoreInvalidEndpoint(), false);
         boolean isAggregateOnException = parseBoolean(definition.getAggregateOnException(), false);
 
-        Enricher enricher = new Enricher(exp);
+        Enricher enricher;
+        if (definition.getExpression() instanceof ConstantExpression) {
+            Expression exp = createExpression(definition.getExpression());
+            Exchange ex = new DefaultExchange(camelContext);
+            String uri = exp.evaluate(ex, String.class);
+            enricher = new Enricher(exp, uri);
+        } else {
+            Expression exp = createExpression(definition.getExpression());
+            String uri = definition.getExpression().getExpression();
+            enricher = new Enricher(exp, uri);
+        }
+
         enricher.setShareUnitOfWork(isShareUnitOfWork);
         enricher.setIgnoreInvalidEndpoint(isIgnoreInvalidEndpoint);
         enricher.setAggregateOnException(isAggregateOnException);
@@ -55,6 +68,9 @@ public class EnrichReifier extends ExpressionReifier<EnrichDefinition> {
         if (definition.getAllowOptimisedComponents() != null) {
             enricher.setAllowOptimisedComponents(parseBoolean(definition.getAllowOptimisedComponents(), true));
         }
+        if (definition.getAutoStartComponents() != null) {
+            enricher.setAutoStartupComponents(parseBoolean(definition.getAutoStartComponents(), true));
+        }
 
         return enricher;
     }
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/PollEnrichReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/PollEnrichReifier.java
index ce6ae59e665..36d43a27205 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/PollEnrichReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/PollEnrichReifier.java
@@ -44,11 +44,12 @@ public class PollEnrichReifier extends ProcessorReifier<PollEnrichDefinition> {
         if (definition.getExpression() instanceof ConstantExpression) {
             Expression exp = createExpression(definition.getExpression());
             Exchange ex = new DefaultExchange(camelContext);
-            String dest = exp.evaluate(ex, String.class);
-            enricher = new PollEnricher(dest, time);
+            String uri = exp.evaluate(ex, String.class);
+            enricher = new PollEnricher(uri, time);
         } else {
             Expression exp = createExpression(definition.getExpression());
-            enricher = new PollEnricher(exp, time);
+            String uri = definition.getExpression().getExpression();
+            enricher = new PollEnricher(exp, uri, time);
         }
 
         AggregationStrategy strategy = getConfiguredAggregationStrategy(definition);
@@ -61,6 +62,9 @@ public class PollEnrichReifier extends ProcessorReifier<PollEnrichDefinition> {
         }
         enricher.setIgnoreInvalidEndpoint(isIgnoreInvalidEndpoint);
         enricher.setAggregateOnException(isAggregateOnException);
+        if (definition.getAutoStartComponents() != null) {
+            enricher.setAutoStartupComponents(parseBoolean(definition.getAutoStartComponents(), true));
+        }
 
         return enricher;
     }
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ToDynamicReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ToDynamicReifier.java
index 40a51c22bcc..f9fb814c5d8 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ToDynamicReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ToDynamicReifier.java
@@ -76,7 +76,7 @@ public class ToDynamicReifier<T extends ToDynamicDefinition> extends ProcessorRe
         // make sure to parse property placeholders
         uri = EndpointHelper.resolveEndpointUriPropertyPlaceholders(camelContext, uri);
 
-        // we use simple language by default but you can configure a different language
+        // we use simple language by default, but you can configure a different language
         String language = "simple";
         if (uri.startsWith("language:")) {
             String value = StringHelper.after(uri, "language:");
diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
index 84cf0cc12f8..49bf724f710 100644
--- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
+++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
@@ -390,6 +390,7 @@ public class ModelParser extends BaseParser {
                 case "aggregationStrategyMethodAllowNull": def.setAggregationStrategyMethodAllowNull(val); break;
                 case "aggregationStrategyMethodName": def.setAggregationStrategyMethodName(val); break;
                 case "allowOptimisedComponents": def.setAllowOptimisedComponents(val); break;
+                case "autoStartComponents": def.setAutoStartComponents(val); break;
                 case "cacheSize": def.setCacheSize(val); break;
                 case "ignoreInvalidEndpoint": def.setIgnoreInvalidEndpoint(val); break;
                 case "shareUnitOfWork": def.setShareUnitOfWork(val); break;
@@ -743,6 +744,7 @@ public class ModelParser extends BaseParser {
                 case "aggregationStrategy": def.setAggregationStrategy(val); break;
                 case "aggregationStrategyMethodAllowNull": def.setAggregationStrategyMethodAllowNull(val); break;
                 case "aggregationStrategyMethodName": def.setAggregationStrategyMethodName(val); break;
+                case "autoStartComponents": def.setAutoStartComponents(val); break;
                 case "cacheSize": def.setCacheSize(val); break;
                 case "ignoreInvalidEndpoint": def.setIgnoreInvalidEndpoint(val); break;
                 case "timeout": def.setTimeout(val); break;
diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
index f64fde80adf..5167687a41c 100644
--- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
+++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
@@ -1224,6 +1224,7 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("cacheSize", def.getCacheSize());
         doWriteAttribute("aggregationStrategy", def.getAggregationStrategy());
         doWriteAttribute("ignoreInvalidEndpoint", def.getIgnoreInvalidEndpoint());
+        doWriteAttribute("autoStartComponents", def.getAutoStartComponents());
         doWriteAttribute("allowOptimisedComponents", def.getAllowOptimisedComponents());
         doWriteAttribute("aggregateOnException", def.getAggregateOnException());
         doWriteAttribute("aggregationStrategyMethodName", def.getAggregationStrategyMethodName());
@@ -1734,6 +1735,7 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("cacheSize", def.getCacheSize());
         doWriteAttribute("aggregationStrategy", def.getAggregationStrategy());
         doWriteAttribute("ignoreInvalidEndpoint", def.getIgnoreInvalidEndpoint());
+        doWriteAttribute("autoStartComponents", def.getAutoStartComponents());
         doWriteAttribute("aggregateOnException", def.getAggregateOnException());
         doWriteAttribute("aggregationStrategyMethodName", def.getAggregationStrategyMethodName());
         doWriteAttribute("timeout", def.getTimeout());
diff --git a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java
index 603c2ed5ac2..403cf7e9724 100644
--- a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java
+++ b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java
@@ -1224,6 +1224,7 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("cacheSize", def.getCacheSize());
         doWriteAttribute("aggregationStrategy", def.getAggregationStrategy());
         doWriteAttribute("ignoreInvalidEndpoint", def.getIgnoreInvalidEndpoint());
+        doWriteAttribute("autoStartComponents", def.getAutoStartComponents());
         doWriteAttribute("allowOptimisedComponents", def.getAllowOptimisedComponents());
         doWriteAttribute("aggregateOnException", def.getAggregateOnException());
         doWriteAttribute("aggregationStrategyMethodName", def.getAggregationStrategyMethodName());
@@ -1734,6 +1735,7 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("cacheSize", def.getCacheSize());
         doWriteAttribute("aggregationStrategy", def.getAggregationStrategy());
         doWriteAttribute("ignoreInvalidEndpoint", def.getIgnoreInvalidEndpoint());
+        doWriteAttribute("autoStartComponents", def.getAutoStartComponents());
         doWriteAttribute("aggregateOnException", def.getAggregateOnException());
         doWriteAttribute("aggregationStrategyMethodName", def.getAggregationStrategyMethodName());
         doWriteAttribute("timeout", def.getTimeout());
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
index b913c3f78eb..ec52adcc75e 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
@@ -4934,6 +4934,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
                     @YamlProperty(name = "aggregationStrategyMethodAllowNull", type = "string", description = "If this option is false then the aggregate method is not used if there was no data to enrich. If this option is true then null values is used as the oldExchange (when no data to enrich), when using POJOs as the AggregationStrategy.", displayName = "Aggregation Strategy Method Allow Null"),
                     @YamlProperty(name = "aggregationStrategyMethodName", type = "string", description = "This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy.", displayName = "Aggregation Strategy Method Name"),
                     @YamlProperty(name = "allowOptimisedComponents", type = "boolean", description = "Whether to allow components to optimise enricher if they are org.apache.camel.spi.SendDynamicAware .", displayName = "Allow Optimised Components"),
+                    @YamlProperty(name = "autoStartComponents", type = "boolean", description = "Whether to auto startup components when enricher is starting up.", displayName = "Auto Start Components"),
                     @YamlProperty(name = "cacheSize", type = "number", description = "Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producer when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic endpoint is unique then its best to turn off caching by setting this to -1, which allows Camel to not cache both the producers and endpoints; they are regarded as p [...]
                     @YamlProperty(name = "description", type = "string", description = "Sets the description of this node", displayName = "Description"),
                     @YamlProperty(name = "disabled", type = "boolean", description = "Whether to disable this EIP from the route during build time. Once an EIP has been disabled then it cannot be enabled later at runtime.", displayName = "Disabled"),
@@ -4984,6 +4985,11 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
                     target.setAllowOptimisedComponents(val);
                     break;
                 }
+                case "autoStartComponents": {
+                    String val = asText(node);
+                    target.setAutoStartComponents(val);
+                    break;
+                }
                 case "cacheSize": {
                     String val = asText(node);
                     target.setCacheSize(val);
@@ -11170,6 +11176,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
                     @YamlProperty(name = "aggregationStrategy", type = "string", description = "Sets the AggregationStrategy to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message.", displayName = "Aggregation Strategy"),
                     @YamlProperty(name = "aggregationStrategyMethodAllowNull", type = "string", description = "If this option is false then the aggregate method is not used if there was no data to enrich. If this option is true then null values is used as the oldExchange (when no data to enrich), when using POJOs as the AggregationStrategy.", displayName = "Aggregation Strategy Method Allow Null"),
                     @YamlProperty(name = "aggregationStrategyMethodName", type = "string", description = "This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy.", displayName = "Aggregation Strategy Method Name"),
+                    @YamlProperty(name = "autoStartComponents", type = "boolean", description = "Whether to auto startup components when poll enricher is starting up.", displayName = "Auto Start Components"),
                     @YamlProperty(name = "cacheSize", type = "number", description = "Sets the maximum size used by the org.apache.camel.spi.ConsumerCache which is used to cache and reuse consumers when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic endpoint is unique then its best to turn off caching by setting this to -1, which allows Camel to not cache both the producers and endpoints; they are regarded as  [...]
                     @YamlProperty(name = "description", type = "string", description = "Sets the description of this node", displayName = "Description"),
                     @YamlProperty(name = "disabled", type = "boolean", description = "Whether to disable this EIP from the route during build time. Once an EIP has been disabled then it cannot be enabled later at runtime.", displayName = "Disabled"),
@@ -11215,6 +11222,11 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
                     target.setAggregationStrategyMethodName(val);
                     break;
                 }
+                case "autoStartComponents": {
+                    String val = asText(node);
+                    target.setAutoStartComponents(val);
+                    break;
+                }
                 case "cacheSize": {
                     String val = asText(node);
                     target.setCacheSize(val);
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
index 5593b355f78..6cab3898979 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
@@ -1220,6 +1220,11 @@
             "title" : "Allow Optimised Components",
             "description" : "Whether to allow components to optimise enricher if they are org.apache.camel.spi.SendDynamicAware ."
           },
+          "autoStartComponents" : {
+            "type" : "boolean",
+            "title" : "Auto Start Components",
+            "description" : "Whether to auto startup components when enricher is starting up."
+          },
           "cacheSize" : {
             "type" : "number",
             "title" : "Cache Size",
@@ -3646,6 +3651,11 @@
             "title" : "Aggregation Strategy Method Name",
             "description" : "This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy."
           },
+          "autoStartComponents" : {
+            "type" : "boolean",
+            "title" : "Auto Start Components",
+            "description" : "Whether to auto startup components when poll enricher is starting up."
+          },
           "cacheSize" : {
             "type" : "number",
             "title" : "Cache Size",