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 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.camel.spi.RouteControllercontroller(org.apache.camel.Route route) org.apache.camel.spi.ExceptionHandlerprotected voidHandles 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) voidvoidstopRouteAsync(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, doStart, doStop, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
RoutePolicySupport
public RoutePolicySupport()
-
-
Method Details
-
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
Starts the consumer.- Throws:
Exception- See Also:
-
stopConsumer
Stops the consumer.- Throws:
Exception- See Also:
-
suspendOrStopConsumer
Suspends 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:
-
resumeOrStartConsumer
Resumes 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:
-
startRoute
- Throws:
Exception
-
resumeRoute
- Throws:
Exception
-
suspendRoute
- Throws:
Exception
-
suspendRoute
public void suspendRoute(org.apache.camel.Route route, long timeout, TimeUnit timeUnit) throws Exception - Throws:
Exception
-
stopRoute
- Throws:
Exception- See Also:
-
stopRoute
public void stopRoute(org.apache.camel.Route route, long timeout, TimeUnit timeUnit) throws Exception - Throws:
Exception- See Also:
-
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
Handles the given exception using thegetExceptionHandler()- Parameters:
t- the exception to handle
-
getExceptionHandler
public org.apache.camel.spi.ExceptionHandler getExceptionHandler() -
setExceptionHandler
public void setExceptionHandler(org.apache.camel.spi.ExceptionHandler exceptionHandler)
-