Class RoutePolicySupport

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.RoutePolicy, org.apache.camel.StatefulService, org.apache.camel.SuspendableService
    Direct Known Subclasses:
    ThrottlingExceptionRoutePolicy, ThrottlingInflightRoutePolicy

    public abstract class RoutePolicySupport
    extends org.apache.camel.support.service.ServiceSupport
    implements org.apache.camel.spi.RoutePolicy
    A base class for developing custom RoutePolicy implementations.
    • Field Summary

      • Fields inherited from class org.apache.camel.support.service.BaseService

        BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.apache.camel.spi.RouteController controller​(org.apache.camel.Route route)  
      protected void doStart()  
      protected void doStop()  
      org.apache.camel.spi.ExceptionHandler getExceptionHandler()  
      protected void handleException​(Throwable t)
      Handles the given exception using the getExceptionHandler()
      void onExchangeBegin​(org.apache.camel.Route route, org.apache.camel.Exchange exchange)  
      void onExchangeDone​(org.apache.camel.Route route, org.apache.camel.Exchange exchange)  
      void onInit​(org.apache.camel.Route route)  
      void onRemove​(org.apache.camel.Route route)  
      void onResume​(org.apache.camel.Route route)  
      void onStart​(org.apache.camel.Route route)  
      void onStop​(org.apache.camel.Route route)  
      void onSuspend​(org.apache.camel.Route route)  
      boolean resumeOrStartConsumer​(org.apache.camel.Consumer consumer)
      Resumes or starts the consumer.
      void resumeRoute​(org.apache.camel.Route route)  
      void setExceptionHandler​(org.apache.camel.spi.ExceptionHandler exceptionHandler)  
      void startConsumer​(org.apache.camel.Consumer consumer)
      Starts the consumer.
      void startRoute​(org.apache.camel.Route route)  
      void stopConsumer​(org.apache.camel.Consumer consumer)
      Stops the consumer.
      void stopRoute​(org.apache.camel.Route route)  
      void stopRoute​(org.apache.camel.Route route, long timeout, TimeUnit timeUnit)  
      void stopRouteAsync​(org.apache.camel.Route route)
      Allows to stop a route asynchronously using a separate background thread which can allow any current in-flight exchange to complete while the route is being shutdown.
      boolean suspendOrStopConsumer​(org.apache.camel.Consumer consumer)
      Suspends or stops the consumer.
      void suspendRoute​(org.apache.camel.Route route)  
      void suspendRoute​(org.apache.camel.Route route, long timeout, TimeUnit timeUnit)  
      • Methods inherited from class org.apache.camel.support.service.BaseService

        build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
      • Methods inherited from interface org.apache.camel.Service

        build, close, init, start, stop
      • Methods inherited from interface org.apache.camel.ShutdownableService

        shutdown
      • Methods inherited from interface org.apache.camel.StatefulService

        getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
      • Methods inherited from interface org.apache.camel.SuspendableService

        isSuspended, resume, suspend
    • Constructor Detail

      • RoutePolicySupport

        public RoutePolicySupport()
    • Method Detail

      • onInit

        public void onInit​(org.apache.camel.Route route)
        Specified by:
        onInit in interface org.apache.camel.spi.RoutePolicy
      • onRemove

        public void onRemove​(org.apache.camel.Route route)
        Specified by:
        onRemove in interface org.apache.camel.spi.RoutePolicy
      • onStart

        public void onStart​(org.apache.camel.Route route)
        Specified by:
        onStart in interface org.apache.camel.spi.RoutePolicy
      • onStop

        public void onStop​(org.apache.camel.Route route)
        Specified by:
        onStop in interface org.apache.camel.spi.RoutePolicy
      • onSuspend

        public void onSuspend​(org.apache.camel.Route route)
        Specified by:
        onSuspend in interface org.apache.camel.spi.RoutePolicy
      • onResume

        public void onResume​(org.apache.camel.Route route)
        Specified by:
        onResume in interface org.apache.camel.spi.RoutePolicy
      • onExchangeBegin

        public void onExchangeBegin​(org.apache.camel.Route route,
                                    org.apache.camel.Exchange exchange)
        Specified by:
        onExchangeBegin in interface org.apache.camel.spi.RoutePolicy
      • onExchangeDone

        public void onExchangeDone​(org.apache.camel.Route route,
                                   org.apache.camel.Exchange exchange)
        Specified by:
        onExchangeDone in interface org.apache.camel.spi.RoutePolicy
      • suspendOrStopConsumer

        public boolean suspendOrStopConsumer​(org.apache.camel.Consumer consumer)
                                      throws Exception
        Suspends or stops the consumer. If the consumer is Suspendable then the consumer is suspended, otherwise the consumer is stopped.
        Returns:
        true if the consumer was suspended or stopped, false if the consumer was already suspend or stopped
        Throws:
        Exception
        See Also:
        stopConsumer(Consumer)
      • resumeOrStartConsumer

        public boolean resumeOrStartConsumer​(org.apache.camel.Consumer consumer)
                                      throws Exception
        Resumes or starts the consumer. If the consumer is Suspendable then the consumer is resumed, otherwise the consumer is started.
        Returns:
        true if the consumer was resumed or started, false if the consumer was already resumed or started
        Throws:
        Exception
        See Also:
        startConsumer(Consumer)
      • startRoute

        public void startRoute​(org.apache.camel.Route route)
                        throws Exception
        Throws:
        Exception
      • resumeRoute

        public void resumeRoute​(org.apache.camel.Route route)
                         throws Exception
        Throws:
        Exception
      • suspendRoute

        public void suspendRoute​(org.apache.camel.Route route)
                          throws Exception
        Throws:
        Exception
      • suspendRoute

        public void suspendRoute​(org.apache.camel.Route route,
                                 long timeout,
                                 TimeUnit timeUnit)
                          throws Exception
        Throws:
        Exception
      • stopRouteAsync

        public void stopRouteAsync​(org.apache.camel.Route route)
        Allows to stop a route asynchronously using a separate background thread which can allow any current in-flight exchange to complete while the route is being shutdown. You may attempt to stop a route from processing an exchange which would be in-flight and therefore attempting to stop the route will defer due there is an inflight exchange in-progress. By stopping the route independently using a separate thread ensures the exchange can continue process and complete and the route can be stopped.
      • controller

        protected org.apache.camel.spi.RouteController controller​(org.apache.camel.Route route)
      • handleException

        protected void handleException​(Throwable t)
        Handles the given exception using the getExceptionHandler()
        Parameters:
        t - the exception to handle
      • 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
      • getExceptionHandler

        public org.apache.camel.spi.ExceptionHandler getExceptionHandler()
      • setExceptionHandler

        public void setExceptionHandler​(org.apache.camel.spi.ExceptionHandler exceptionHandler)