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 404cb349079ffc187f4ae6e99b810a7bbdd2433f Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Jun 7 10:06:00 2019 +0200 CAMEL-13515: Allow producer to lazy start until first message --- components/camel-bean/src/main/docs/bean-component.adoc | 6 +++--- components/camel-bean/src/main/docs/class-component.adoc | 6 +++--- .../java/org/apache/camel/component/bean/BeanEndpoint.java | 8 ++++---- .../camel/runtimecatalog/impl/JSonSchemaHelperTest.java | 13 +++++++------ .../main/java/org/apache/camel/support/DefaultEndpoint.java | 10 ++++++---- .../java/org/apache/camel/support/LazyStartProducer.java | 8 ++++---- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/components/camel-bean/src/main/docs/bean-component.adoc b/components/camel-bean/src/main/docs/bean-component.adoc index cb83d31..4c2e622 100644 --- a/components/camel-bean/src/main/docs/bean-component.adoc +++ b/components/camel-bean/src/main/docs/bean-component.adoc @@ -59,11 +59,11 @@ with the following path and query parameters: [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type +| *cache* (common) | If enabled, Camel will cache the result of the first Registry look-up. Cache can be enabled if the bean in the Registry is defined as a singleton scope. | | Boolean +| *method* (common) | Sets the name of the method to invoke on the bean | | String +| *parameters* (common) | Used for configuring additional properties on the bean | | Map | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). | false | boolean -| *method* (producer) | Sets the name of the method to invoke on the bean | | String | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean -| *cache* (advanced) | If enabled, Camel will cache the result of the first Registry look-up. Cache can be enabled if the bean in the Registry is defined as a singleton scope. | | Boolean -| *parameters* (advanced) | Used for configuring additional properties on the bean | | Map | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean |=== // endpoint options: END diff --git a/components/camel-bean/src/main/docs/class-component.adoc b/components/camel-bean/src/main/docs/class-component.adoc index 2f2d466..d4a9e1d 100644 --- a/components/camel-bean/src/main/docs/class-component.adoc +++ b/components/camel-bean/src/main/docs/class-component.adoc @@ -62,11 +62,11 @@ with the following path and query parameters: [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type +| *cache* (common) | If enabled, Camel will cache the result of the first Registry look-up. Cache can be enabled if the bean in the Registry is defined as a singleton scope. | | Boolean +| *method* (common) | Sets the name of the method to invoke on the bean | | String +| *parameters* (common) | Used for configuring additional properties on the bean | | Map | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). | false | boolean -| *method* (producer) | Sets the name of the method to invoke on the bean | | String | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean -| *cache* (advanced) | If enabled, Camel will cache the result of the first Registry look-up. Cache can be enabled if the bean in the Registry is defined as a singleton scope. | | Boolean -| *parameters* (advanced) | Used for configuring additional properties on the bean | | Map | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean |=== // endpoint options: END diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java index 05cbbed..8ceac11 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java +++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java @@ -36,14 +36,14 @@ import org.apache.camel.support.DefaultEndpoint; public class BeanEndpoint extends DefaultEndpoint { private transient BeanHolder beanHolder; private transient BeanProcessor processor; - @UriPath(description = "Sets the name of the bean to invoke") @Metadata(required = true) + @UriPath(label = "common", description = "Sets the name of the bean to invoke") @Metadata(required = true) private String beanName; - @UriParam(description = "Sets the name of the method to invoke on the bean") + @UriParam(label = "common", description = "Sets the name of the method to invoke on the bean") private String method; - @UriParam(label = "advanced", description = "If enabled, Camel will cache the result of the first Registry look-up." + @UriParam(label = "common", description = "If enabled, Camel will cache the result of the first Registry look-up." + " Cache can be enabled if the bean in the Registry is defined as a singleton scope.") private Boolean cache; - @UriParam(prefix = "bean.", label = "advanced", description = "Used for configuring additional properties on the bean", multiValue = true) + @UriParam(prefix = "bean.", label = "common", description = "Used for configuring additional properties on the bean", multiValue = true) private Map<String, Object> parameters; public BeanEndpoint() { diff --git a/core/camel-core/src/test/java/org/apache/camel/runtimecatalog/impl/JSonSchemaHelperTest.java b/core/camel-core/src/test/java/org/apache/camel/runtimecatalog/impl/JSonSchemaHelperTest.java index 24c7461..a9c3c44 100644 --- a/core/camel-core/src/test/java/org/apache/camel/runtimecatalog/impl/JSonSchemaHelperTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/runtimecatalog/impl/JSonSchemaHelperTest.java @@ -54,13 +54,14 @@ public class JSonSchemaHelperTest extends ContextTestSupport { assertEquals("version", rows.get(16).keySet().iterator().next()); rows = JSonSchemaHelper.parseJsonSchema("properties", json, true); - assertEquals(6, rows.size()); + assertEquals(7, rows.size()); assertEquals("beanName", rows.get(0).values().iterator().next()); - assertEquals("method", rows.get(1).values().iterator().next()); - assertEquals("basicPropertyBinding", rows.get(2).values().iterator().next()); - assertEquals("cache", rows.get(3).values().iterator().next()); - assertEquals("parameters", rows.get(4).values().iterator().next()); - assertEquals("synchronous", rows.get(5).values().iterator().next()); + assertEquals("cache", rows.get(1).values().iterator().next()); + assertEquals("method", rows.get(2).values().iterator().next()); + assertEquals("parameters", rows.get(3).values().iterator().next()); + assertEquals("lazyStartProducer", rows.get(4).values().iterator().next()); + assertEquals("basicPropertyBinding", rows.get(5).values().iterator().next()); + assertEquals("synchronous", rows.get(6).values().iterator().next()); } @Test diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java index 1e2b551..712b4ff 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultEndpoint.java @@ -57,7 +57,9 @@ public abstract class DefaultEndpoint extends ServiceSupport implements Endpoint private CamelContext camelContext; private Component component; @UriParam(label = "producer", - description = "Whether the producer should be started lazy (on the first message).") + description = "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup" + + " in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then" + + " the startup failure can be handled during routing messages via Camel's routing error handlers.") private boolean lazyStartProducer; @UriParam(label = "consumer", optionalPrefix = "consumer.", description = "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." @@ -259,8 +261,6 @@ public abstract class DefaultEndpoint extends ServiceSupport implements Endpoint /** * Sets whether synchronous processing should be strictly used, or Camel is * allowed to use asynchronous processing (if supported). - * - * @param synchronous <tt>true</tt> to enforce synchronous processing */ public void setSynchronous(boolean synchronous) { this.synchronous = synchronous; @@ -285,7 +285,9 @@ public abstract class DefaultEndpoint extends ServiceSupport implements Endpoint } /** - * Whether the producer should be started lazy (on the first message). + * Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup + * in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then + * the startup failure can be handled during routing messages via Camel's routing error handlers. */ public void setLazyStartProducer(boolean lazyStartProducer) { this.lazyStartProducer = lazyStartProducer; diff --git a/core/camel-support/src/main/java/org/apache/camel/support/LazyStartProducer.java b/core/camel-support/src/main/java/org/apache/camel/support/LazyStartProducer.java index 32336b3..363ab8a 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/LazyStartProducer.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/LazyStartProducer.java @@ -1,13 +1,13 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.