Class DefaultSupervisingRouteController

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.impl.engine.DefaultRouteController
org.apache.camel.impl.engine.DefaultSupervisingRouteController
All Implemented Interfaces:
AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.NonManagedService, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.RouteController, org.apache.camel.spi.SupervisingRouteController, org.apache.camel.StatefulService, org.apache.camel.StaticService, org.apache.camel.SuspendableService

public class DefaultSupervisingRouteController extends DefaultRouteController implements org.apache.camel.spi.SupervisingRouteController
A supervising capable RouteController that delays the startup of the routes after the camel context startup and takes control of starting the routes in a safe manner. This controller is able to retry starting failing routes, and have various options to configure settings for backoff between restarting routes.

When a route has been successfully started, then this supervising controller will no longer manage the route and afterward the route is managed by the default route controller. The supervising capabilities are designed to only be in use during the startup of the application.

See Also:
  • Constructor Details

    • DefaultSupervisingRouteController

      public DefaultSupervisingRouteController()
  • Method Details

    • startRoutes

      public void startRoutes(boolean reloaded)
      Specified by:
      startRoutes in interface org.apache.camel.spi.SupervisingRouteController
    • getIncludeRoutes

      public String getIncludeRoutes()
      Specified by:
      getIncludeRoutes in interface org.apache.camel.spi.SupervisingRouteController
    • setIncludeRoutes

      public void setIncludeRoutes(String includeRoutes)
      Specified by:
      setIncludeRoutes in interface org.apache.camel.spi.SupervisingRouteController
    • getExcludeRoutes

      public String getExcludeRoutes()
      Specified by:
      getExcludeRoutes in interface org.apache.camel.spi.SupervisingRouteController
    • setExcludeRoutes

      public void setExcludeRoutes(String excludeRoutes)
      Specified by:
      setExcludeRoutes in interface org.apache.camel.spi.SupervisingRouteController
    • getThreadPoolSize

      public int getThreadPoolSize()
      Specified by:
      getThreadPoolSize in interface org.apache.camel.spi.SupervisingRouteController
    • setThreadPoolSize

      public void setThreadPoolSize(int threadPoolSize)
      Specified by:
      setThreadPoolSize in interface org.apache.camel.spi.SupervisingRouteController
    • getInitialDelay

      public long getInitialDelay()
      Specified by:
      getInitialDelay in interface org.apache.camel.spi.SupervisingRouteController
    • setInitialDelay

      public void setInitialDelay(long initialDelay)
      Specified by:
      setInitialDelay in interface org.apache.camel.spi.SupervisingRouteController
    • getBackOffDelay

      public long getBackOffDelay()
      Specified by:
      getBackOffDelay in interface org.apache.camel.spi.SupervisingRouteController
    • setBackOffDelay

      public void setBackOffDelay(long backOffDelay)
      Specified by:
      setBackOffDelay in interface org.apache.camel.spi.SupervisingRouteController
    • getBackOffMaxDelay

      public long getBackOffMaxDelay()
      Specified by:
      getBackOffMaxDelay in interface org.apache.camel.spi.SupervisingRouteController
    • setBackOffMaxDelay

      public void setBackOffMaxDelay(long backOffMaxDelay)
      Specified by:
      setBackOffMaxDelay in interface org.apache.camel.spi.SupervisingRouteController
    • getBackOffMaxElapsedTime

      public long getBackOffMaxElapsedTime()
      Specified by:
      getBackOffMaxElapsedTime in interface org.apache.camel.spi.SupervisingRouteController
    • setBackOffMaxElapsedTime

      public void setBackOffMaxElapsedTime(long backOffMaxElapsedTime)
      Specified by:
      setBackOffMaxElapsedTime in interface org.apache.camel.spi.SupervisingRouteController
    • getBackOffMaxAttempts

      public long getBackOffMaxAttempts()
      Specified by:
      getBackOffMaxAttempts in interface org.apache.camel.spi.SupervisingRouteController
    • setBackOffMaxAttempts

      public void setBackOffMaxAttempts(long backOffMaxAttempts)
      Specified by:
      setBackOffMaxAttempts in interface org.apache.camel.spi.SupervisingRouteController
    • getBackOffMultiplier

      public double getBackOffMultiplier()
      Specified by:
      getBackOffMultiplier in interface org.apache.camel.spi.SupervisingRouteController
    • setBackOffMultiplier

      public void setBackOffMultiplier(double backOffMultiplier)
      Specified by:
      setBackOffMultiplier in interface org.apache.camel.spi.SupervisingRouteController
    • isUnhealthyOnExhausted

      public boolean isUnhealthyOnExhausted()
      Specified by:
      isUnhealthyOnExhausted in interface org.apache.camel.spi.SupervisingRouteController
    • setUnhealthyOnExhausted

      public void setUnhealthyOnExhausted(boolean unhealthyOnExhausted)
      Specified by:
      setUnhealthyOnExhausted in interface org.apache.camel.spi.SupervisingRouteController
    • isUnhealthyOnRestarting

      public boolean isUnhealthyOnRestarting()
      Specified by:
      isUnhealthyOnRestarting in interface org.apache.camel.spi.SupervisingRouteController
    • setUnhealthyOnRestarting

      public void setUnhealthyOnRestarting(boolean unhealthyOnRestarting)
      Specified by:
      setUnhealthyOnRestarting in interface org.apache.camel.spi.SupervisingRouteController
    • getBackOff

      protected org.apache.camel.util.backoff.BackOff getBackOff(String id)
    • doInit

      protected void doInit() throws Exception
      Overrides:
      doInit in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • hasUnhealthyRoutes

      public boolean hasUnhealthyRoutes()
      Specified by:
      hasUnhealthyRoutes in interface org.apache.camel.spi.RouteController
      Overrides:
      hasUnhealthyRoutes in class DefaultRouteController
    • isStartingRoutes

      public boolean isStartingRoutes()
      Specified by:
      isStartingRoutes in interface org.apache.camel.spi.RouteController
      Specified by:
      isStartingRoutes in interface org.apache.camel.spi.SupervisingRouteController
      Overrides:
      isStartingRoutes in class DefaultRouteController
    • startRoute

      public void startRoute(String routeId) throws Exception
      Specified by:
      startRoute in interface org.apache.camel.spi.RouteController
      Overrides:
      startRoute in class DefaultRouteController
      Throws:
      Exception
    • stopRoute

      public void stopRoute(String routeId) throws Exception
      Specified by:
      stopRoute in interface org.apache.camel.spi.RouteController
      Overrides:
      stopRoute in class DefaultRouteController
      Throws:
      Exception
    • stopRoute

      public void stopRoute(String routeId, Throwable cause) throws Exception
      Specified by:
      stopRoute in interface org.apache.camel.spi.RouteController
      Overrides:
      stopRoute in class DefaultRouteController
      Throws:
      Exception
    • stopRoute

      public void stopRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception
      Specified by:
      stopRoute in interface org.apache.camel.spi.RouteController
      Overrides:
      stopRoute in class DefaultRouteController
      Throws:
      Exception
    • stopRoute

      public boolean stopRoute(String routeId, long timeout, TimeUnit timeUnit, boolean abortAfterTimeout) throws Exception
      Specified by:
      stopRoute in interface org.apache.camel.spi.RouteController
      Overrides:
      stopRoute in class DefaultRouteController
      Throws:
      Exception
    • suspendRoute

      public void suspendRoute(String routeId) throws Exception
      Specified by:
      suspendRoute in interface org.apache.camel.spi.RouteController
      Overrides:
      suspendRoute in class DefaultRouteController
      Throws:
      Exception
    • suspendRoute

      public void suspendRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception
      Specified by:
      suspendRoute in interface org.apache.camel.spi.RouteController
      Overrides:
      suspendRoute in class DefaultRouteController
      Throws:
      Exception
    • resumeRoute

      public void resumeRoute(String routeId) throws Exception
      Specified by:
      resumeRoute in interface org.apache.camel.spi.RouteController
      Overrides:
      resumeRoute in class DefaultRouteController
      Throws:
      Exception
    • getControlledRoutes

      public Collection<org.apache.camel.Route> getControlledRoutes()
      Specified by:
      getControlledRoutes in interface org.apache.camel.spi.RouteController
      Overrides:
      getControlledRoutes in class DefaultRouteController
    • getRestartingRoutes

      public Collection<org.apache.camel.Route> getRestartingRoutes()
      Specified by:
      getRestartingRoutes in interface org.apache.camel.spi.SupervisingRouteController
    • getExhaustedRoutes

      public Collection<org.apache.camel.Route> getExhaustedRoutes()
      Specified by:
      getExhaustedRoutes in interface org.apache.camel.spi.SupervisingRouteController
    • getNonControlledRouteIds

      public Set<String> getNonControlledRouteIds()
      Specified by:
      getNonControlledRouteIds in interface org.apache.camel.spi.SupervisingRouteController
    • getRestartingRouteState

      public org.apache.camel.util.backoff.BackOffTimer.Task getRestartingRouteState(String routeId)
      Specified by:
      getRestartingRouteState in interface org.apache.camel.spi.SupervisingRouteController
    • getRestartException

      public Throwable getRestartException(String routeId)
      Specified by:
      getRestartException in interface org.apache.camel.spi.SupervisingRouteController