/**
  * Store a notification of the application state and hour
  *
  * @param context of the Camel app
  */
 @Override
 public void onContextStop(CamelContext context) {
   log.debug("Stopped " + context.getName());
   InstanceState instanceState = new InstanceState();
   instanceState.setName(context.getName());
   instanceState.setState(State.Stopped);
   instanceState.setTimestamp(DateTime.now().toString());
   repository.save(instanceState);
 }
Ejemplo n.º 2
0
 /**
  * Adds a set of routing/configuration rules to the host {@link CamelContext} using the supplied
  * {@link RouteLoader}.
  *
  * @param loader The loader for the routes you wish to load.
  */
 public void load(final RouteLoader loader) {
   notNull(loader, "Route loader cannot be null.");
   try {
     log.debug("Adding routes to context {}.", hostContext.getName());
     hostContext.addRoutes(loader.load());
   } catch (Exception e) {
     throw new LifecycleException(e.getLocalizedMessage(), e);
   }
 }
Ejemplo n.º 3
0
  /**
   * Activates the control channel, which will from now on behave in accordance with the routes you
   * set up in your bootstrap script(s).
   *
   * <p>See {@link ControlChannel#waitShutdown} and {@link ControlChannel#sendShutdownSignal()} for
   * instructions on shutting down an activated channel.
   */
  public void activate() {
    try {
      log.info("Activating control channel.");
      final CamelContext context = getContext();

      log.info("Configuring trace interceptor for {}.", context.getName());
      TraceBuilder builder = new TraceBuilder(getConfig(), tracer);
      context.addInterceptStrategy(builder.build());

      log.debug("Starting underlying camel context.");
      context.start();
    } catch (Exception e) {
      throw new LifecycleException(e.getLocalizedMessage(), e);
    }
  }