예제 #1
0
  @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);
  }
예제 #2
0
  protected void doStop() throws Exception {

    // if we are stopping CamelContext then we are shutting down
    boolean isShutdownCamelContext = camelContext.isStopping();

    if (isShutdownCamelContext || isRemovingRoutes()) {
      // need to call onRoutesRemove when the CamelContext is shutting down or Route is shutdown
      for (LifecycleStrategy strategy : camelContext.getLifecycleStrategies()) {
        strategy.onRoutesRemove(routes);
      }
    }

    for (Route route : routes) {
      LOG.debug("Stopping 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);

      // stop services
      stopChildService(route, services, isShutdownCamelContext);

      // stop the route itself
      if (isShutdownCamelContext) {
        ServiceHelper.stopAndShutdownServices(route);
      } else {
        ServiceHelper.stopServices(route);
      }

      // invoke callbacks on route policy
      if (route.getRouteContext().getRoutePolicyList() != null) {
        for (RoutePolicy routePolicy : route.getRouteContext().getRoutePolicyList()) {
          routePolicy.onStop(route);
        }
      }
      // fire event
      EventHelper.notifyRouteStopped(camelContext, route);
    }
    if (isRemovingRoutes()) {
      camelContext.removeRouteCollection(routes);
    }
    // need to warm up again
    warmUpDone.set(false);
  }