Seems like a bug
Here is a full dependencyManagement and dependencies parts of pom.xml made
according to https://camel.apache.org/camel-spring-boot/latest/index.html
<dependencyManagement>
<dependencies>
<!-- Camel BOM -->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-bom</artifactId>
<version>${camel-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- ... other BOMs or dependencies ... -->
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Camel Starter -->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
<!-- ... other dependencies ... -->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-activemq-starter</artifactId>
</dependency>
</dependencies>
The main method looks like
@SpringBootApplication
@ImportResource("classpath:camel.xml")
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
Logs, where I have camel got started twice with 2 routes and 0 routes
respectively
2021-01-26 20:23:00.242 INFO 27189 --- [ main]
o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.7.1 (camel) is
starting
2021-01-26 20:23:00.244 INFO 27189 --- [ main]
o.a.c.impl.engine.AbstractCamelContext : StreamCaching is not in use. If
using streams then it's recommended to enable stream caching. See more details
at http://camel.apache.org/stream-caching.html
2021-01-26 20:23:00.272 INFO 27189 --- [ main]
c.s.b.CamelSpringBootApplicationListener : Starting CamelMainRunController to
ensure the main thread keeps running
2021-01-26 20:23:00.275 INFO 27189 --- [ main]
o.a.c.i.e.InternalRouteStartupManager : Route: my.route started and
consuming from: file:///home/camel/in
2021-01-26 20:23:00.276 INFO 27189 --- [ main]
o.a.c.i.e.InternalRouteStartupManager : Route: another.route started and
consuming from: direct://routing
2021-01-26 20:23:00.279 INFO 27189 --- [ main]
o.a.c.impl.engine.AbstractCamelContext : Total 2 routes, of which 2 are
started
2021-01-26 20:23:00.280 INFO 27189 --- [ main]
o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.7.1 (camel) started
in 38ms
2021-01-26 20:23:00.292 INFO 27189 --- [ main]
o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.7.1 (camel) is
starting
2021-01-26 20:23:00.293 INFO 27189 --- [ main]
o.a.c.impl.engine.AbstractCamelContext : StreamCaching is not in use. If
using streams then it's recommended to enable stream caching. See more details
at http://camel.apache.org/stream-caching.html
2021-01-26 20:23:00.293 INFO 27189 --- [ main]
o.a.c.impl.engine.AbstractCamelContext : Total 0 routes, of which 0 are
started
2021-01-26 20:23:00.293 INFO 27189 --- [ main]
o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.7.1 (camel) started
in 1ms
2021-01-26 20:23:00.300 INFO 27189 --- [ main] as2.MyApplication
: Started MyApplication in 4.558 seconds (JVM running for
5.694)
The problem disappears if I remove ImportResource annotation, but how one could
set onException or InterceptFrom blocks in this case?
________________________________
От: Иванов Григорий Олегович <[email protected]>
Отправлено: 26 января 2021 г. 17:28:58
Кому: [email protected]
Тема: Re: migration to Camel 3.7
I figured out it is related to having camelContext described in camel.xml along
with another beans and for example camel-activemq-starter dependency in pom.xml
The one way to eliminate camelContext reloading is to drop camelContext
description at all, xml routes then could be placed in classpath directory to
be load. But I have interceptFrom, onException and others described in my
camelContext bean, where should I move it now?
Or, I noticed using the camel-activemq from org.apache.camel instead of
camel-activemq-starter from org.apache.camel.springboot also helps, would it be
correct?
Please, help
________________________________
От: Иванов Григорий Олегович <[email protected]>
Отправлено: 23 декабря 2020 г. 15:03:34
Кому: [email protected]
Тема: migration to Camel 3.7
Hi,
I have an issue when migrated from 3.5 to 3.7 Camel
According to logs there are 4 additional empty (0 routes) camel contexts being
started (camel-1 to camel-4)
Please tell if it is a feature and if so what is its purpose? Should I care
about these contexts or somehow treat them?
Camel 3.7.0, Spring Boot 2.4.1
Here is the logs, thanks in advance!
14:46:01.152 [main ] INFO pl.engine.AbstractCamelContext - Total 51
routes, of which 51 are started
14:46:01.152 [main ] INFO pl.engine.AbstractCamelContext - Apache
Camel 3.7.0 (camel) started in 3s362ms
14:46:01.193 [main ] INFO nagement.JmxManagementStrategy - JMX is
enabled
14:46:01.194 [main ] INFO pl.engine.AbstractCamelContext - Apache
Camel 3.7.0 (camel) is starting
14:46:01.195 [main ] WARN JmxManagementLifecycleStrategy - This
CamelContext(camel) will be registered using the name: camel-1 due to clash
with an existing name already registered in MBeanServer.
14:46:01.215 [main ] INFO pl.engine.AbstractCamelContext -
StreamCaching is not in use. If using streams then it's recommended to enable
stream caching. See more details at http://camel.apache.org/stream-caching.html
14:46:01.221 [main ] INFO pl.engine.AbstractCamelContext - Total 0
routes, of which 0 are started
14:46:01.223 [main ] INFO pl.engine.AbstractCamelContext - Apache
Camel 3.7.0 (camel) started in 29ms
14:46:01.236 [main ] INFO nagement.JmxManagementStrategy - JMX is
enabled
14:46:01.236 [main ] INFO pl.engine.AbstractCamelContext - Apache
Camel 3.7.0 (camel) is starting
14:46:01.236 [main ] WARN JmxManagementLifecycleStrategy - This
CamelContext(camel) will be registered using the name: camel-2 due to clash
with an existing name already registered in MBeanServer.
14:46:01.262 [main ] INFO pl.engine.AbstractCamelContext -
StreamCaching is not in use. If using streams then it's recommended to enable
stream caching. See more details at http://camel.apache.org/stream-caching.html
14:46:01.280 [main ] INFO pl.engine.AbstractCamelContext - Total 0
routes, of which 0 are started
14:46:01.283 [main ] INFO pl.engine.AbstractCamelContext - Apache
Camel 3.7.0 (camel) started in 47ms
14:46:01.294 [main ] INFO nagement.JmxManagementStrategy - JMX is
enabled
14:46:01.295 [main ] INFO pl.engine.AbstractCamelContext - Apache
Camel 3.7.0 (camel) is starting
14:46:01.298 [main ] WARN JmxManagementLifecycleStrategy - This
CamelContext(camel) will be registered using the name: camel-3 due to clash
with an existing name already registered in MBeanServer.
14:46:01.347 [main ] INFO pl.engine.AbstractCamelContext -
StreamCaching is not in use. If using streams then it's recommended to enable
stream caching. See more details at http://camel.apache.org/stream-caching.html
14:46:01.356 [main ] INFO pl.engine.AbstractCamelContext - Total 0
routes, of which 0 are started
14:46:01.356 [main ] INFO pl.engine.AbstractCamelContext - Apache
Camel 3.7.0 (camel) started in 61ms
14:46:01.396 [main ] INFO nagement.JmxManagementStrategy - JMX is
enabled
14:46:01.398 [main ] INFO pl.engine.AbstractCamelContext - Apache
Camel 3.7.0 (camel) is starting
14:46:01.399 [main ] WARN JmxManagementLifecycleStrategy - This
CamelContext(camel) will be registered using the name: camel-4 due to clash
with an existing name already registered in MBeanServer.
14:46:01.451 [main ] INFO pl.engine.AbstractCamelContext -
StreamCaching is not in use. If using streams then it's recommended to enable
stream caching. See more details at http://camel.apache.org/stream-caching.html
14:46:01.463 [main ] INFO pl.engine.AbstractCamelContext - Total 0
routes, of which 0 are started
14:46:01.463 [main ] INFO pl.engine.AbstractCamelContext - Apache
Camel 3.7.0 (camel) started in 64ms
14:46:01.474 [main ] INFO phere.sample.CamelApplication - Started
CamelApplication in 13.587 seconds (JVM running for 16.829)