Package org.apache.camel.impl.engine
Class DurationRoutePolicy
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.RoutePolicySupport
org.apache.camel.impl.engine.DurationRoutePolicy
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.RoutePolicy,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
public class DurationRoutePolicy
extends org.apache.camel.support.RoutePolicySupport
implements org.apache.camel.CamelContextAware
RoutePolicy which executes for a duration and then triggers an action.
This can be used to stop the route after it has processed a number of messages, or has been running for N seconds.-
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
ConstructorsConstructorDescriptionDurationRoutePolicy(org.apache.camel.CamelContext camelContext, String routeId) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStop()org.apache.camel.impl.engine.DurationRoutePolicy.Actionorg.apache.camel.CamelContextintintvoidonExchangeDone(org.apache.camel.Route route, org.apache.camel.Exchange exchange) voidonInit(org.apache.camel.Route route) protected ScheduledFutureprotected voidvoidsetAction(org.apache.camel.impl.engine.DurationRoutePolicy.Action action) What action to perform when maximum is triggered.voidsetCamelContext(org.apache.camel.CamelContext camelContext) voidsetMaxMessages(int maxMessages) Maximum number of messages to process before the action is triggeredvoidsetMaxSeconds(int maxSeconds) Maximum seconds Camel is running before the action is triggeredMethods inherited from class org.apache.camel.support.RoutePolicySupport
controller, getExceptionHandler, handleException, onExchangeBegin, onRemove, onResume, onStart, onStop, onSuspend, resumeOrStartConsumer, resumeRoute, setExceptionHandler, startConsumer, startRoute, stopConsumer, stopRoute, stopRoute, stopRouteAsync, suspendOrStopConsumer, suspendRoute, suspendRouteMethods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doStart, doSuspend, fail, 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
-
DurationRoutePolicy
public DurationRoutePolicy() -
DurationRoutePolicy
-
-
Method Details
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()- Specified by:
getCamelContextin interfaceorg.apache.camel.CamelContextAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
getMaxMessages
public int getMaxMessages() -
setMaxMessages
public void setMaxMessages(int maxMessages) Maximum number of messages to process before the action is triggered -
getMaxSeconds
public int getMaxSeconds() -
setMaxSeconds
public void setMaxSeconds(int maxSeconds) Maximum seconds Camel is running before the action is triggered -
getAction
public org.apache.camel.impl.engine.DurationRoutePolicy.Action getAction() -
setAction
public void setAction(org.apache.camel.impl.engine.DurationRoutePolicy.Action action) What action to perform when maximum is triggered. -
onInit
public void onInit(org.apache.camel.Route route) - Specified by:
onInitin interfaceorg.apache.camel.spi.RoutePolicy- Overrides:
onInitin classorg.apache.camel.support.RoutePolicySupport
-
onExchangeDone
public void onExchangeDone(org.apache.camel.Route route, org.apache.camel.Exchange exchange) - Specified by:
onExchangeDonein interfaceorg.apache.camel.spi.RoutePolicy- Overrides:
onExchangeDonein classorg.apache.camel.support.RoutePolicySupport
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
performMaxMessagesAction
protected void performMaxMessagesAction() -
performMaxDurationAction
-