Package org.apache.camel.spi
Interface RouteController
-
- All Superinterfaces:
AutoCloseable,CamelContextAware,Service,StaticService
- All Known Subinterfaces:
SupervisingRouteController
public interface RouteController extends CamelContextAware, StaticService
Controller for managing the lifecycle of all theRoute's.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends RouteController>
Tadapt(Class<T> type)Adapts thisRouteControllerto the specialized type.Collection<Route>getControlledRoutes()Return the list of routes controlled by this controller.LoggingLevelgetLoggingLevel()Gets the logging level used for logging route activity (such as starting and stopping routes).ServiceStatusgetRouteStatus(String routeId)Returns the current status of the given routebooleanisReloadingRoutes()Indicates whether current thread is reloading route(s).booleanisStartingRoutes()Indicates whether current thread is starting route(s).booleanisSupervising()Whether this route controller is a regular or supervising controller.voidreloadAllRoutes()Reloads all the routesvoidremoveAllRoutes()Stops and removes all the routesvoidresumeRoute(String routeId)Resumes the given route if it has been previously suspendedvoidsetLoggingLevel(LoggingLevel loggingLevel)Sets the logging level used for logging route activity (such as starting and stopping routes).voidstartAllRoutes()Starts all the routes which currently is not started.voidstartRoute(String routeId)Starts the given route if it has been previously stoppedvoidstopAllRoutes()Stops all the routesvoidstopRoute(String routeId)Stops the given route usingShutdownStrategy.voidstopRoute(String routeId, long timeout, TimeUnit timeUnit)Stops the given route usingShutdownStrategywith a specified timeout.booleanstopRoute(String routeId, long timeout, TimeUnit timeUnit, boolean abortAfterTimeout)Stops the given route usingShutdownStrategywith a specified timeout and optional abortAfterTimeout mode.voidstopRoute(String routeId, Throwable cause)Stops and marks the given route as failed (health check is DOWN) due to a caused exception.SupervisingRouteControllersupervising()Enables supervisingRouteController.voidsuspendRoute(String routeId)Suspends the given route usingShutdownStrategy.voidsuspendRoute(String routeId, long timeout, TimeUnit timeUnit)Suspends the given route usingShutdownStrategywith a specified timeout.-
Methods inherited from interface org.apache.camel.CamelContextAware
getCamelContext, setCamelContext
-
-
-
-
Method Detail
-
getLoggingLevel
LoggingLevel getLoggingLevel()
Gets the logging level used for logging route activity (such as starting and stopping routes). The default logging level is DEBUG.
-
setLoggingLevel
void setLoggingLevel(LoggingLevel loggingLevel)
Sets the logging level used for logging route activity (such as starting and stopping routes). The default logging level is DEBUG.
-
isSupervising
boolean isSupervising()
Whether this route controller is a regular or supervising controller.
-
supervising
SupervisingRouteController supervising()
Enables supervisingRouteController.
-
adapt
<T extends RouteController> T adapt(Class<T> type)
Adapts thisRouteControllerto the specialized type. For example to adapt to SupervisingRouteController.- Parameters:
type- the type to adapt to- Returns:
- this
CamelContextadapted to the given type
-
getControlledRoutes
Collection<Route> getControlledRoutes()
Return the list of routes controlled by this controller.- Returns:
- the list of controlled routes
-
startAllRoutes
void startAllRoutes() throws ExceptionStarts all the routes which currently is not started.- Throws:
Exception- is thrown if a route could not be started for whatever reason
-
stopAllRoutes
void stopAllRoutes() throws ExceptionStops all the routes- Throws:
Exception- is thrown if a route could not be stopped for whatever reason
-
removeAllRoutes
void removeAllRoutes() throws ExceptionStops and removes all the routes- Throws:
Exception- is thrown if a route could not be stopped or removed for whatever reason
-
isStartingRoutes
boolean isStartingRoutes()
Indicates whether current thread is starting route(s). This can be useful to know byLifecycleStrategyor the likes, in case they need to react differently.- Returns:
- true if current thread is starting route(s), or false if not.
-
reloadAllRoutes
void reloadAllRoutes() throws ExceptionReloads all the routes- Throws:
Exception- is thrown if a route could not be reloaded for whatever reason
-
isReloadingRoutes
boolean isReloadingRoutes()
Indicates whether current thread is reloading route(s). This can be useful to know byLifecycleStrategyor the likes, in case they need to react differently.- Returns:
- true if current thread is reloading route(s), or false if not.
-
getRouteStatus
ServiceStatus getRouteStatus(String routeId)
Returns the current status of the given route- Parameters:
routeId- the route id- Returns:
- the status for the route
-
startRoute
void startRoute(String routeId) throws Exception
Starts the given route if it has been previously stopped- Parameters:
routeId- the route id- Throws:
Exception- is thrown if the route could not be started for whatever reason
-
stopRoute
void stopRoute(String routeId) throws Exception
Stops the given route usingShutdownStrategy.- Parameters:
routeId- the route id- Throws:
Exception- is thrown if the route could not be stopped for whatever reason- See Also:
suspendRoute(String)
-
stopRoute
void stopRoute(String routeId, Throwable cause) throws Exception
Stops and marks the given route as failed (health check is DOWN) due to a caused exception.- Parameters:
routeId- the route idcause- the exception that is causing this route to be stopped and marked as failed- Throws:
Exception- is thrown if the route could not be stopped for whatever reason- See Also:
suspendRoute(String)
-
stopRoute
void stopRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception
Stops the given route usingShutdownStrategywith a specified timeout.- Parameters:
routeId- the route idtimeout- timeouttimeUnit- the unit to use- Throws:
Exception- is thrown if the route could not be stopped for whatever reason- See Also:
suspendRoute(String, long, java.util.concurrent.TimeUnit)
-
stopRoute
boolean stopRoute(String routeId, long timeout, TimeUnit timeUnit, boolean abortAfterTimeout) throws Exception
Stops the given route usingShutdownStrategywith a specified timeout and optional abortAfterTimeout mode.- Parameters:
routeId- the route idtimeout- timeouttimeUnit- the unit to useabortAfterTimeout- should abort shutdown after timeout- Returns:
- true if the route is stopped before the timeout
- Throws:
Exception- is thrown if the route could not be stopped for whatever reason- See Also:
suspendRoute(String, long, java.util.concurrent.TimeUnit)
-
suspendRoute
void suspendRoute(String routeId) throws Exception
Suspends the given route usingShutdownStrategy. Suspending a route is more gently than stopping, as the route consumers will be suspended (if they support) otherwise the consumers will be stopped. By suspending the route services will be kept running (if possible) and therefore its faster to resume the route. If the route does not support suspension the route will be stopped instead- Parameters:
routeId- the route id- Throws:
Exception- is thrown if the route could not be suspended for whatever reason
-
suspendRoute
void suspendRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception
Suspends the given route usingShutdownStrategywith a specified timeout. Suspending a route is more gently than stopping, as the route consumers will be suspended (if they support) otherwise the consumers will be stopped. By suspending the route services will be kept running (if possible) and therefore its faster to resume the route. If the route does not support suspension the route will be stopped instead- Parameters:
routeId- the route idtimeout- timeouttimeUnit- the unit to use- Throws:
Exception- is thrown if the route could not be suspended for whatever reason
-
resumeRoute
void resumeRoute(String routeId) throws Exception
Resumes the given route if it has been previously suspended If the route does not support suspension the route will be started instead- Parameters:
routeId- the route id- Throws:
Exception- is thrown if the route could not be resumed for whatever reason
-
-