Package org.apache.camel.support
Class RoutePolicySupport
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.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 customRoutePolicy
implementations.
-
-
Constructor Summary
Constructors Constructor Description RoutePolicySupport()
-
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 thegetExceptionHandler()
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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
onInit
public void onInit(org.apache.camel.Route route)
- Specified by:
onInit
in interfaceorg.apache.camel.spi.RoutePolicy
-
onRemove
public void onRemove(org.apache.camel.Route route)
- Specified by:
onRemove
in interfaceorg.apache.camel.spi.RoutePolicy
-
onStart
public void onStart(org.apache.camel.Route route)
- Specified by:
onStart
in interfaceorg.apache.camel.spi.RoutePolicy
-
onStop
public void onStop(org.apache.camel.Route route)
- Specified by:
onStop
in interfaceorg.apache.camel.spi.RoutePolicy
-
onSuspend
public void onSuspend(org.apache.camel.Route route)
- Specified by:
onSuspend
in interfaceorg.apache.camel.spi.RoutePolicy
-
onResume
public void onResume(org.apache.camel.Route route)
- Specified by:
onResume
in interfaceorg.apache.camel.spi.RoutePolicy
-
onExchangeBegin
public void onExchangeBegin(org.apache.camel.Route route, org.apache.camel.Exchange exchange)
- Specified by:
onExchangeBegin
in interfaceorg.apache.camel.spi.RoutePolicy
-
onExchangeDone
public void onExchangeDone(org.apache.camel.Route route, org.apache.camel.Exchange exchange)
- Specified by:
onExchangeDone
in interfaceorg.apache.camel.spi.RoutePolicy
-
startConsumer
public void startConsumer(org.apache.camel.Consumer consumer) throws Exception
Starts the consumer.- Throws:
Exception
- See Also:
resumeOrStartConsumer(Consumer)
-
stopConsumer
public void stopConsumer(org.apache.camel.Consumer consumer) throws Exception
Stops the consumer.- Throws:
Exception
- See Also:
suspendOrStopConsumer(Consumer)
-
suspendOrStopConsumer
public boolean suspendOrStopConsumer(org.apache.camel.Consumer consumer) throws Exception
Suspends or stops the consumer. If the consumer isSuspendable
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 isSuspendable
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)
-
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
-
stopRoute
public void stopRoute(org.apache.camel.Route route) throws Exception
- Throws:
Exception
- See Also:
stopRouteAsync(Route)
-
stopRoute
public void stopRoute(org.apache.camel.Route route, long timeout, TimeUnit timeUnit) throws Exception
- Throws:
Exception
- See Also:
stopRouteAsync(Route)
-
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 thegetExceptionHandler()
- Parameters:
t
- the exception to handle
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classorg.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)
-
-