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 61dd5f7e185297d462ae900f2b8730b42faad525 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Mar 17 15:31:11 2021 +0100 CAMEL-116340: Ensure components are started when CamelContext is starting. --- .../camel/impl/engine/AbstractCamelContext.java | 33 ++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java index c638bd5..d86be48 100644 --- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java +++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java @@ -2830,20 +2830,8 @@ public abstract class AbstractCamelContext extends BaseService startDate = System.currentTimeMillis(); stopWatch.restart(); - // ensure components are started - for (Map.Entry<String, Component> entry : components.entrySet()) { - StartupStep step = startupStepRecorder.beginStep(Component.class, entry.getKey(), "Start Component"); - try { - ServiceHelper.startService(entry.getValue()); - } catch (Exception e) { - throw new FailedToStartComponentException(entry.getKey(), e.getMessage(), e); - } finally { - startupStepRecorder.endStep(step); - } - } - // Start the route controller - ServiceHelper.startService(this.routeController); + startService(this.routeController); doNotStartRoutesOnFirstStart = !firstStartDone && !isAutoStartup(); @@ -3067,7 +3055,7 @@ public abstract class AbstractCamelContext extends BaseService if (!lifecycleStrategies.isEmpty()) { StartupStep subStep = startupStepRecorder.beginStep(CamelContext.class, getName(), "LifecycleStrategy onContextStarting"); - ServiceHelper.startService(lifecycleStrategies); + startServices(lifecycleStrategies); for (LifecycleStrategy strategy : lifecycleStrategies) { try { strategy.onContextStarting(this); @@ -3086,6 +3074,18 @@ public abstract class AbstractCamelContext extends BaseService startupStepRecorder.endStep(subStep); } + // ensure components are started + for (Map.Entry<String, Component> entry : components.entrySet()) { + StartupStep step = startupStepRecorder.beginStep(Component.class, entry.getKey(), "Start Component"); + try { + startService(entry.getValue()); + } catch (Exception e) { + throw new FailedToStartComponentException(entry.getKey(), e.getMessage(), e); + } finally { + startupStepRecorder.endStep(step); + } + } + if (!startupListeners.isEmpty()) { StartupStep subStep = startupStepRecorder.beginStep(CamelContext.class, getName(), "StartupListener onCamelContextStarting"); @@ -3109,9 +3109,6 @@ public abstract class AbstractCamelContext extends BaseService // must let some bootstrap service be started before we can notify the starting event EventHelper.notifyCamelContextStarting(this); - // start components - startServices(components.values()); - if (isUseDataType()) { // log if DataType has been enabled LOG.info("Message DataType is enabled on CamelContext: {}", getName()); @@ -3468,7 +3465,7 @@ public abstract class AbstractCamelContext extends BaseService aware.setCamelContext(getCamelContextReference()); } - service.start(); + ServiceHelper.startService(service); } private void startServices(Collection<?> services) throws Exception {