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

Zoran Regvart commented on CAMEL-11476:
---------------------------------------

I've found the issue and a possible solution, I'm running tests to see if the 
solution caused any other issues.

The problem is that the equality check in 
[RoutesCollector.java#L81|https://github.com/apache/camel/blob/master/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java#L81]
 does not pass when {{management.port=8081}} is set. And this in turn is 
because 
[EndpointWebMvcAutoConfiguration.java#L144|https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java#L144]
 instantiates a new {{ApplicationContext}} instance if the management port is 
customized.

So previously {{RoutesCollector} would start {{CamelContext}} but now 
{{CamelContext}} is started by {{ContextRefreshedEvent}}, and it is started on 
the first {{ContextRefreshedEvent}} for the first {{ApplicationContext}}, and 
as {{RoutesCollector}} checks if its a part of that {{AppplicationContext}} it 
won't add {{RouteBuilders}}, and the second {{ContextRefreshedEvent}} from the 
second {{ApplicationContext}} does not load any {{RouteBuilders}} as at that 
point {{CamelContext}} is already started and the second check in  
[RoutesCollector.java#L86|https://github.com/apache/camel/blob/master/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java#L86]
 will not pass.


> spring-boot - routes not loaded when setting a management.port
> --------------------------------------------------------------
>
>                 Key: CAMEL-11476
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11476
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-spring-boot
>    Affects Versions: 2.20.0
>            Reporter: Nicola Ferraro
>            Assignee: Zoran Regvart
>             Fix For: 2.20.0
>
>
> This is a really weird bug. If you set:
> {code}
> management.port=8081
> {code}
> On the application.properties file of any spring-boot application using 
> actuator, then camel routes created through RouteBuilders are not loaded 
> ("Total 0 routes, of which 0 are started."). 
> I've found it in (all) the fabric8 basic quickstarts, but it happens also in 
> the "camel-example-spring-boot" bundled with Apache Camel. Everything works 
> in 2.19.x.
> Setting a different management port is a best practice. 
> [~zregvart], [~cib...@e-ma.net], [~lb] any idea?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to