You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ff...@apache.org on 2021/03/02 14:36:31 UTC

[camel] branch camel-2.25.x updated: [CAMEL-16063]don't start camel context if event is from the self management ApplicationContext

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

ffang pushed a commit to branch camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.25.x by this push:
     new dcdd921  [CAMEL-16063]don't start camel context if event is from the self management ApplicationContext
dcdd921 is described below

commit dcdd92199839960a4762ac5065d010403fe183f1
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Tue Mar 2 09:35:53 2021 -0500

    [CAMEL-16063]don't start camel context if event is from the self management ApplicationContext
---
 .../main/java/org/apache/camel/spring/boot/RoutesCollector.java   | 5 ++---
 .../java/org/apache/camel/spring/CamelContextFactoryBean.java     | 8 ++++++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
index a52e215..077771d 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
@@ -84,9 +84,8 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
         CamelContext camelContext = applicationContext.getBean(CamelContext.class);
 
         // only add and start Camel if its stopped (initial state)
-        if ((event.getApplicationContext() == this.applicationContext
-            || event.getApplicationContext().getParent() == this.applicationContext)
-                && camelContext.getStatus().isStopped()) {
+        if (event.getApplicationContext() == this.applicationContext
+            && camelContext.getStatus().isStopped()) {
             LOG.debug("Post-processing CamelContext bean: {}", camelContext.getName());
 
             final AntPathMatcher matcher = new AntPathMatcher();
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
index d4709c0..b6a5e4d 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
@@ -414,6 +414,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
         // being started/refreshed, there could be a race condition with
         // other ApplicationListeners that react to
         // ContextRefreshedEvent but this is the best that we can do
+        if (event.getSource() instanceof ApplicationContext) {
+            ApplicationContext appCtx = (ApplicationContext)event.getSource();
+            if (appCtx.getId().equals("application:management")) {
+                //don't start camel context if 
+                //event is from the self management ApplicationContext
+                return;
+            }
+        }
         start();
     }