Package org.apache.camel.spi
Interface RouteController
- All Superinterfaces:
AutoCloseable
,CamelContextAware
,HasCamelContext
,Service
,StaticService
- All Known Subinterfaces:
SupervisingRouteController
Controller for managing the lifecycle of all the
Route
's.-
Method Summary
Modifier and TypeMethodDescription<T extends RouteController>
TAdapts thisRouteController
to the specialized type.Return the list of routes controlled by this controller.Gets the logging level used for logging route activity (such as starting and stopping routes).getRouteStatus
(String routeId) Returns the current status of the given routeboolean
Indicates if the route controller has routes that are currently unhealthy such as they have not yet been successfully started, and if being supervised then the route can either be pending restarts or failed all restart attempts and are exhausted.boolean
Indicates whether current thread is reloading route(s).boolean
Indicates whether the route controller is doing initial starting of the routes.boolean
Whether this route controller is a regular or supervising controller.void
Reloads all the routesvoid
Stops and removes all the routesvoid
resumeRoute
(String routeId) Resumes the given route if it has been previously suspendedvoid
setLoggingLevel
(LoggingLevel loggingLevel) Sets the logging level used for logging route activity (such as starting and stopping routes).void
Starts all the routes which currently is not started.void
startRoute
(String routeId) Starts the given route if it has been previously stoppedvoid
Stops all the routesvoid
Stops the given route usingShutdownStrategy
.void
Stops the given route usingShutdownStrategy
with a specified timeout.boolean
Stops the given route usingShutdownStrategy
with a specified timeout and optional abortAfterTimeout mode.void
Stops and marks the given route as failed (health check is DOWN) due to a caused exception.Enables supervisingRouteController
.void
suspendRoute
(String routeId) Suspends the given route usingShutdownStrategy
.void
suspendRoute
(String routeId, long timeout, TimeUnit timeUnit) Suspends the given route usingShutdownStrategy
with a specified timeout.Methods inherited from interface org.apache.camel.CamelContextAware
setCamelContext
Methods inherited from interface org.apache.camel.spi.HasCamelContext
getCamelContext
-
Method Details
-
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
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
Adapts thisRouteController
to the specialized type. For example to adapt to SupervisingRouteController.- Parameters:
type
- the type to adapt to- Returns:
- this
CamelContext
adapted to the given type
-
getControlledRoutes
Collection<Route> getControlledRoutes()Return the list of routes controlled by this controller.- Returns:
- the list of controlled routes
-
startAllRoutes
Starts all the routes which currently is not started.- Throws:
Exception
- is thrown if a route could not be started for whatever reason
-
stopAllRoutes
Stops all the routes- Throws:
Exception
- is thrown if a route could not be stopped for whatever reason
-
removeAllRoutes
Stops 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 the route controller is doing initial starting of the routes. -
hasUnhealthyRoutes
boolean hasUnhealthyRoutes()Indicates if the route controller has routes that are currently unhealthy such as they have not yet been successfully started, and if being supervised then the route can either be pending restarts or failed all restart attempts and are exhausted. -
reloadAllRoutes
Reloads 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 byLifecycleStrategy
or the likes, in case they need to react differently.- Returns:
- true if current thread is reloading route(s), or false if not.
-
getRouteStatus
Returns the current status of the given route- Parameters:
routeId
- the route id- Returns:
- the status for the route
-
startRoute
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
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:
-
stopRoute
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:
-
stopRoute
Stops the given route usingShutdownStrategy
with 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:
-
stopRoute
boolean stopRoute(String routeId, long timeout, TimeUnit timeUnit, boolean abortAfterTimeout) throws Exception Stops the given route usingShutdownStrategy
with 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
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
Suspends the given route usingShutdownStrategy
with 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
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
-