[ 
https://issues.apache.org/jira/browse/CAMEL-12905?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16667003#comment-16667003
 ] 

ASF GitHub Bot commented on CAMEL-12905:
----------------------------------------

zregvart closed pull request #2581: CAMEL-12905: Camel context inconsistencies 
in Spring Cloud Environment 
URL: https://github.com/apache/camel/pull/2581
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 54f2064c391..d378e3162be 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,7 +84,8 @@ public void onApplicationEvent(ContextRefreshedEvent event) {
         CamelContext camelContext = 
applicationContext.getBean(CamelContext.class);
 
         // only add and start Camel if its stopped (initial state)
-        if (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/SpringCamelContext.java
 
b/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
index e32e581566b..b4dba29728d 100644
--- 
a/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
+++ 
b/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
@@ -159,7 +159,7 @@ public void stop() {
     public void onApplicationEvent(ApplicationEvent event) {
         LOG.debug("onApplicationEvent: {}", event);
 
-        if (event instanceof ContextRefreshedEvent) {
+        if (event instanceof ContextRefreshedEvent && ((ContextRefreshedEvent) 
event).getApplicationContext() == this.applicationContext) {
             // nominally we would prefer to use Lifecycle interface that
             // would invoke start() method, but in order to do that 
             // SpringCamelContext needs to implement SmartLifecycle


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Camel context inconsistencies in Spring Cloud Environment 
> ----------------------------------------------------------
>
>                 Key: CAMEL-12905
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12905
>             Project: Camel
>          Issue Type: Bug
>            Reporter: omar alles
>            Priority: Major
>
> In a Spring Cloud environment some components might create a child 
> application context that spring cloud mantains. Such is the case for Feign 
> and Ribbon Clients.
> See 7.2 - 
> [https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-feign.html]
>  "A central concept in Spring Cloud’s Feign support is that of the named 
> client. Each feign client is part of an ensemble of components that work 
> together to contact a remote server on demand, and the ensemble has a name 
> that you give it as an application developer using the @FeignClient 
> annotation. Spring Cloud creates a new ensemble as an ApplicationContext on 
> demand for each named client using FeignClientsConfiguration."
> This child application contexts are going to be an ApplicationEvent source 
> for the SpringCamelContext and RoutesCollector component who are defined as  
> ApplicationEvent listeners in a parent context.
> SpringCamelContext is intended to be started after a ContextRefreshedEvent.
>  RoutesCollector intends to add routes to the camel context after a 
> ContextRefreshedEvent.
> When there are child application contexts (ContextRefreshedEvent emitters)  
> we end up having some inconsistencies in the camel context lifecycle.
>  
> To reproduce the issue see:
> [https://github.com/oalles/camel-cloud-bug]
>  
> Pull Request:
> https://github.com/apache/camel/pull/2581
>  
>  
>  
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to