You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Alexey Vinogradov <al...@db.com> on 2011/05/24 15:02:19 UTC
camelContext autoStartup=false does not prevent Camel from starting
when Spring context starts
The result I want to achieve is to start Camel context only after Spring
context.start() completes.
The solution with using camelContext autoStartup=false described
http://camel.apache.org/configuring-route-startup-ordering-and-autostartup.html
works with Camel 2.4.0 but fails to work with Camel 2.7.1. The way
autoStartup is implemented currently it duplicates the functionality that
can be achieved by setting autoStartup for all the routes. It looks like
currently there is no way to prevent Camel starting when Spring starts. The
change that drove to this was
https://issues.apache.org/jira/browse/CAMEL-3008.
I proppose that org.apache.camel.spring.SpringCamelContext#maybeStart should
check isAutoStartup and do nothing in case of false. This will allow to
start CamelContext later programmatically.
And it would be perfect if
org.apache.camel.spring.SpringCamelContext#onApplicationEvent proccessed the
org.springframework.context.event.ContextStartedEvent and started
CamelContext even if the isAutoStartup is false.
--
View this message in context: http://camel.465427.n5.nabble.com/camelContext-autoStartup-false-does-not-prevent-Camel-from-starting-when-Spring-context-starts-tp4421992p4421992.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camelContext autoStartup=false does not prevent Camel from
starting when Spring context starts
Posted by Alexey Vinogradov <al...@db.com>.
I propose the following patch for org.apache.camel.spring.SpringCamelContext
public void afterPropertiesSet() throws Exception {
if(!isAutoStartup()){
maybeStart();
}
}
and the second fix
public void onApplicationEvent(ApplicationEvent event) {
if (LOG.isDebugEnabled()) {
LOG.debug("onApplicationEvent: " + event);
}
if (event instanceof ContextRefreshedEvent && !isAutoStartup() ||
event instanceof ContextStartedEvent) {
// now lets start the CamelContext so that all its possible
// dependencies are initialized
try {
maybeStart();
} catch (Exception e) {
throw wrapRuntimeCamelException(e);
}
} else if (event instanceof ContextStoppedEvent) {
try {
maybeStop();
} catch (Exception e) {
throw wrapRuntimeCamelException(e);
}
}
if (eventEndpoint != null) {
eventEndpoint.onApplicationEvent(event);
} else {
LOG.info("No spring-event endpoint enabled to handle event: " +
event);
}
}
--
View this message in context: http://camel.465427.n5.nabble.com/camelContext-autoStartup-false-does-not-prevent-Camel-from-starting-when-Spring-context-starts-tp4421992p4425168.html
Sent from the Camel - Users mailing list archive at Nabble.com.