Esempio n. 1
0
 private void dumpCamelContext(String msg) {
   LOGGER.debug("\n\n***************  START: " + msg + "  *****************");
   List<RouteDefinition> routeDefinitions = camelContext.getRouteDefinitions();
   if (routeDefinitions != null) {
     LOGGER.debug("Number of routes = " + routeDefinitions.size());
     for (RouteDefinition routeDef : routeDefinitions) {
       String routeId = routeDef.getId();
       LOGGER.debug("route ID = " + routeId);
       List<FromDefinition> routeInputs = routeDef.getInputs();
       if (routeInputs.isEmpty()) {
         LOGGER.debug("routeInputs are EMPTY");
       } else {
         for (FromDefinition fromDef : routeInputs) {
           LOGGER.debug("route input's URI = " + fromDef.getUri());
         }
       }
       ServiceStatus routeStatus = camelContext.getRouteStatus(routeId);
       if (routeStatus != null) {
         LOGGER.debug("Route ID " + routeId + " is started = " + routeStatus.isStarted());
       } else {
         LOGGER.debug("routeStatus is NULL for routeId = " + routeId);
       }
     }
   }
   LOGGER.debug("***************  END: " + msg + "  *****************\n\n");
 }
Esempio n. 2
0
 public Integer getStartedRoutes() {
   int started = 0;
   for (Route route : context.getRoutes()) {
     if (context.getRouteStatus(route.getId()).isStarted()) {
       started++;
     }
   }
   return started;
 }
Esempio n. 3
0
 public String getState() {
   // must use String type to be sure remote JMX can read the attribute without requiring Camel
   // classes.
   ServiceStatus status = context.getRouteStatus(route.getId());
   // if no status exists then its stopped
   if (status == null) {
     status = ServiceStatus.Stopped;
   }
   return status.name();
 }
Esempio n. 4
0
 private void startRoute(RouteDefinition routeDef) {
   String routeId = routeDef.getId();
   try {
     if (isMyRoute(routeId)) {
       ServiceStatus routeStatus = camelContext.getRouteStatus(routeId);
       // Only start the route if it is not already started
       if (routeStatus == null || !routeStatus.isStarted()) {
         LOGGER.trace("Starting route with ID = " + routeId);
         camelContext.startRoute(routeDef); // DEPRECATED
         // this method does not reliably start a route that was created, then
         // app shutdown, and restarted
         //                camelContext.startRoute(routeId);
       }
     }
   } catch (Exception e) {
     LOGGER.warn("Unable to start Camel route with route ID = " + routeId, e);
   }
 }