@Override protected void doShutdown() throws Exception { for (Route route : routes) { LOG.debug("Shutting down services on route: {}", route.getId()); // gather list of services to stop as we need to start child services as well Set<Service> services = gatherChildServices(route, true); // shutdown services stopChildService(route, services, true); // shutdown the route itself ServiceHelper.stopAndShutdownServices(route); // endpoints should only be stopped when Camel is shutting down // see more details in the warmUp method ServiceHelper.stopAndShutdownServices(route.getEndpoint()); // invoke callbacks on route policy if (route.getRouteContext().getRoutePolicyList() != null) { for (RoutePolicy routePolicy : route.getRouteContext().getRoutePolicyList()) { routePolicy.onRemove(route); } } // fire event EventHelper.notifyRouteRemoved(camelContext, route); } // need to call onRoutesRemove when the CamelContext is shutting down or Route is shutdown for (LifecycleStrategy strategy : camelContext.getLifecycleStrategies()) { strategy.onRoutesRemove(routes); } // remove the routes from the inflight registry for (Route route : routes) { camelContext.getInflightRepository().removeRoute(route.getId()); } // remove the routes from the collections camelContext.removeRouteCollection(routes); // clear inputs on shutdown inputs.clear(); warmUpDone.set(false); endpointDone.set(false); }