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.RouteController
controller
(org.apache.camel.Route route) org.apache.camel.spi.ExceptionHandler
protected void
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
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, 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, suspend
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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 Details
-
RoutePolicySupport
public RoutePolicySupport()
-
-
Method Details
-
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
Starts the consumer.- Throws:
Exception
- See Also:
-
stopConsumer
Stops the consumer.- Throws:
Exception
- See Also:
-
suspendOrStopConsumer
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:
-
resumeOrStartConsumer
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:
-
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)
-