protected void onJobExecute(Action action, Route route) throws Exception { LOG.debug( "Scheduled Event notification received. Performing action: {} on route: {}", action, route.getId()); ServiceStatus routeStatus = route.getRouteContext().getCamelContext().getRouteStatus(route.getId()); if (action == Action.START) { if (routeStatus == ServiceStatus.Stopped) { startRoute(route); // here we just check the states of the Consumer } else if (ServiceHelper.isSuspended(route.getConsumer())) { startConsumer(route.getConsumer()); } } else if (action == Action.STOP) { if ((routeStatus == ServiceStatus.Started) || (routeStatus == ServiceStatus.Suspended)) { stopRoute(route, getRouteStopGracePeriod(), getTimeUnit()); } else { LOG.warn( "Route is not in a started/suspended state and cannot be stopped. The current route state is {}", routeStatus); } } else if (action == Action.SUSPEND) { if (routeStatus == ServiceStatus.Started) { stopConsumer(route.getConsumer()); } else { LOG.warn( "Route is not in a started state and cannot be suspended. The current route state is {}", routeStatus); } } else if (action == Action.RESUME) { if (routeStatus == ServiceStatus.Started) { if (ServiceHelper.isSuspended(route.getConsumer())) { startConsumer(route.getConsumer()); } else { LOG.warn("The Consumer {} is not suspended and cannot be resumed.", route.getConsumer()); } } else { LOG.warn( "Route is not in a started state and cannot be resumed. The current route state is {}", routeStatus); } } }