Hey Zoran,

I didn't use SmartLifeCycle for a particular reason, it was just a leftover
of trying stuff :).
As for the fix in the PR I tried it and it didn't work, I see the same
behaviour as with the workaround without the loop. Here are some logs:

16:58:32.026 [Thread-3] INFO  o.a.c.m.MainSupport$HangupInterceptor -
Received hang up - stopping the main instance.
16:58:32.026 [Thread-3] DEBUG org.apache.camel.main.MainSupport - Controller
is shutting down CamelContext
16:58:32.026 [Thread-4] INFO  o.s.c.a.AnnotationConfigApplicationContext -
Closing
org.springframework.context.annotation.AnnotationConfigApplicationContext@51399530:
startup date [Fri May 12 16:58:12 EEST 2017]; root of context hierarchy
16:58:32.026 [CamelMainRunController] DEBUG
o.a.c.s.b.CamelSpringBootApplicationController - Waiting for CamelContext to
complete shutdown
16:58:32.026 [Thread-3] INFO  o.a.camel.spring.SpringCamelContext - Apache
Camel 2.20.0-SNAPSHOT (CamelContext: camel) is shutting down
16:58:32.028 [Thread-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning cached instance of singleton bean 'sqlSessionFactory'
16:58:32.029 [Thread-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning cached instance of singleton bean 'sqlSessionFactorySecondary'
16:58:32.029 [Thread-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning cached instance of singleton bean 'camel'
16:58:32.031 [Thread-3] INFO  o.a.c.impl.DefaultShutdownStrategy - Starting
to graceful shutdown 10 routes (timeout 300 seconds)
....
16:58:32.033 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking
destroy method 'shutdown' on bean with name 'direct-component'
16:58:32.040 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking
destroy method 'shutdown' on bean with name 'file-component'
...
16:58:32.067 [Thread-4] INFO  com.zaxxer.hikari.pool.HikariPool - HikariCP
pool HikariPool-1 is shutting down.
16:58:32.107 [Thread #2 - ShutdownTask] INFO  org.apache.zookeeper.ZooKeeper
- Session: 0x15ac81624a033cd closed
....
16:58:33.080 [Thread-3] INFO  o.a.camel.spring.SpringCamelContext - Apache
Camel 2.20.0-SNAPSHOT (CamelContext: camel) uptime 8.856 seconds
16:58:33.080 [Thread-3] INFO  o.a.camel.spring.SpringCamelContext - Apache
Camel 2.20.0-SNAPSHOT (CamelContext: camel) is shutdown in 1.054 seconds
16:58:33.080 [CamelMainRunController] DEBUG
o.a.c.s.b.CamelSpringBootApplicationController - CamelContext shutdown
complete.

As you can see the beans are destroyed before camel context is shut down. I
said that the shutdown of routes is done asychronously because I noticed in
the logs that a different thread is used for shutting down routes (Thread
#2), a different thread by DefaultShutdownStrategy (Thread-3) and a
different thread for destroying Spring beans (Thread-4). 

Giannis



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-spring-boot-destroys-beans-with-wrong-order-tp5799304p5799390.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to