Skip to content

Commit

Permalink
CAMEL-5561: ExecutorServiceManagement should shutdown after services
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/camel/branches/camel-2.9.x@1391376 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
davsclaus committed Sep 28, 2012
1 parent 3629a76 commit 157082a
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -866,7 +866,10 @@ public synchronized void suspendRoute(String routeId, long timeout, TimeUnit tim
}

public void addService(Object object) throws Exception {
doAddService(object, true);
}

private void doAddService(Object object, boolean closeOnShutdown) throws Exception {
// inject CamelContext
if (object instanceof CamelContextAware) {
CamelContextAware aware = (CamelContextAware) object;
Expand Down Expand Up @@ -894,7 +897,7 @@ public void addService(Object object) throws Exception {
// do not add endpoints as they have their own list
if (singleton && !(service instanceof Endpoint)) {
// only add to list of services to close if its not already there
if (!hasService(service)) {
if (closeOnShutdown && !hasService(service)) {
servicesToClose.add(service);
}
}
Expand Down Expand Up @@ -1512,7 +1515,8 @@ private void doStartCamel() throws Exception {
// and we needed to create endpoints up-front as it may be accessed before this context is started
endpoints = new EndpointRegistry(this, endpoints);
addService(endpoints);
addService(executorServiceManager);
// special for executorServiceManager as want to stop it manually
doAddService(executorServiceManager, false);
addService(producerServicePool);
addService(inflightRepository);
addService(shutdownStrategy);
Expand Down Expand Up @@ -1596,7 +1600,8 @@ protected synchronized void doStop() throws Exception {
shutdownServices(notifier);
}

// shutdown management as the last one
// shutdown executor service and management as the last one
shutdownServices(executorServiceManager);
shutdownServices(managementStrategy);
shutdownServices(lifecycleStrategies);
// do not clear lifecycleStrategies as we can start Camel again and get the route back as before
Expand Down

0 comments on commit 157082a

Please sign in to comment.