Hello Zoran,
thank you for the input it was really helpful. I tried it and although I can
see that now the camel context definately shuts down first, the other beans
are still shut down before camel context is closed probably because the
shutdown of routes happen asychronously. What I ended up doing to overcome
this issue is to place a loop inside my 'SmartLifecycle' bean to wait for
the camel context to close. Here is my workaround:
public class SpringBootCamelFix implements SmartLifecycle {
private static final Logger log =
LoggerFactory.getLogger(SpringBootCamelFix.class);
@Autowired
DefaultCamelContext context;
@Override
public void start() {}
@Override
public void stop() {
if (!isRunning()) {
log.info("Camel context already stopped");
return;
}
log.info("Stopping camel context. Will wait until it is actually
stopped");
try {
context.stop();
} catch (Exception e) {
e.printStackTrace();
}
while(context.isStarted());
}
@Override
public boolean isRunning() {
return context.isStarted();
}
@Override
public int getPhase() {
return Integer.MAX_VALUE;
}
@Override
public boolean isAutoStartup() {
return false;
}
@Override
public void stop(Runnable callback) {
stop();
callback.run();
}
}
I would also like to test your changes however where can I get a jar with
your changes in order to test it locally?
Thanks,
Giannis
--
View this message in context:
http://camel.465427.n5.nabble.com/Camel-spring-boot-destroys-beans-with-wrong-order-tp5799304p5799359.html
Sent from the Camel - Users mailing list archive at Nabble.com.