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.RoutePolicyA base class for developing customRoutePolicyimplementations.
-
-
Constructor Summary
Constructors Constructor Description RoutePolicySupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.camel.spi.RouteControllercontroller(org.apache.camel.Route route)protected voiddoStart()protected voiddoStop()org.apache.camel.spi.ExceptionHandlergetExceptionHandler()protected voidhandleException(Throwable t)Handles the given exception using thegetExceptionHandler()voidonExchangeBegin(org.apache.camel.Route route, org.apache.camel.Exchange exchange)voidonExchangeDone(org.apache.camel.Route route, org.apache.camel.Exchange exchange)voidonInit(org.apache.camel.Route route)voidonRemove(org.apache.camel.Route route)voidonResume(org.apache.camel.Route route)voidonStart(org.apache.camel.Route route)voidonStop(org.apache.camel.Route route)voidonSuspend(org.apache.camel.Route route)booleanresumeOrStartConsumer(org.apache.camel.Consumer consumer)Resumes or starts the consumer.voidresumeRoute(org.apache.camel.Route route)voidsetExceptionHandler(org.apache.camel.spi.ExceptionHandler exceptionHandler)voidstartConsumer(org.apache.camel.Consumer consumer)Starts the consumer.voidstartRoute(org.apache.camel.Route route)voidstopConsumer(org.apache.camel.Consumer consumer)Stops the consumer.voidstopRoute(org.apache.camel.Route route)voidstopRoute(org.apache.camel.Route route, long timeout, TimeUnit timeUnit)voidstopRouteAsync(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.booleansuspendOrStopConsumer(org.apache.camel.Consumer consumer)Suspends or stops the consumer.voidsuspendRoute(org.apache.camel.Route route)voidsuspendRoute(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:
onInitin interfaceorg.apache.camel.spi.RoutePolicy
-
onRemove
public void onRemove(org.apache.camel.Route route)
- Specified by:
onRemovein interfaceorg.apache.camel.spi.RoutePolicy
-
onStart
public void onStart(org.apache.camel.Route route)
- Specified by:
onStartin interfaceorg.apache.camel.spi.RoutePolicy
-
onStop
public void onStop(org.apache.camel.Route route)
- Specified by:
onStopin interfaceorg.apache.camel.spi.RoutePolicy
-
onSuspend
public void onSuspend(org.apache.camel.Route route)
- Specified by:
onSuspendin interfaceorg.apache.camel.spi.RoutePolicy
-
onResume
public void onResume(org.apache.camel.Route route)
- Specified by:
onResumein interfaceorg.apache.camel.spi.RoutePolicy
-
onExchangeBegin
public void onExchangeBegin(org.apache.camel.Route route, org.apache.camel.Exchange exchange)- Specified by:
onExchangeBeginin interfaceorg.apache.camel.spi.RoutePolicy
-
onExchangeDone
public void onExchangeDone(org.apache.camel.Route route, org.apache.camel.Exchange exchange)- Specified by:
onExchangeDonein interfaceorg.apache.camel.spi.RoutePolicy
-
startConsumer
public void startConsumer(org.apache.camel.Consumer consumer) throws ExceptionStarts the consumer.- Throws:
Exception- See Also:
resumeOrStartConsumer(Consumer)
-
stopConsumer
public void stopConsumer(org.apache.camel.Consumer consumer) throws ExceptionStops the consumer.- Throws:
Exception- See Also:
suspendOrStopConsumer(Consumer)
-
suspendOrStopConsumer
public boolean suspendOrStopConsumer(org.apache.camel.Consumer consumer) throws ExceptionSuspends or stops the consumer. If the consumer isSuspendablethen 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 ExceptionResumes or starts the consumer. If the consumer isSuspendablethen 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:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
protected void doStop() throws Exception- Overrides:
doStopin 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)
-
-