org.apache.camel.impl
Class RoutePolicySupport

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.impl.RoutePolicySupport
All Implemented Interfaces:
Service, ShutdownableService, RoutePolicy, StatefulService, SuspendableService
Direct Known Subclasses:
ThrottlingInflightRoutePolicy

public abstract class RoutePolicySupport
extends ServiceSupport
implements RoutePolicy

A base class for developing custom RoutePolicy implementations.

Version:

Field Summary
protected  org.slf4j.Logger log
           
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
RoutePolicySupport()
           
 
Method Summary
protected  void doStart()
          Implementations override this method to support customized start/stop.
protected  void doStop()
          Implementations override this method to support customized start/stop.
 ExceptionHandler getExceptionHandler()
           
protected  void handleException(Throwable t)
          Handles the given exception using the getExceptionHandler()
 void onExchangeBegin(Route route, Exchange exchange)
          Callback invoked when an Exchange is started being routed on the given Route
 void onExchangeDone(Route route, Exchange exchange)
          Callback invoked when an Exchange is done being routed, where it started from the given Route

Notice this callback is invoked when the Exchange is done and the Route is the route where the Exchange was started.

 void onInit(Route route)
          Callback invoked when the Route is being initialized
 void onRemove(Route route)
          Callback invoked when the Route is being removed from CamelContext
 void onResume(Route route)
          Callback invoked when the Route is being resumed
 void onStart(Route route)
          Callback invoked when the Route is being started
 void onStop(Route route)
          Callback invoked when the Route is being stopped
 void onSuspend(Route route)
          Callback invoked when the Route is being suspended
protected  void resumeRoute(Route route)
           
 void setExceptionHandler(ExceptionHandler exceptionHandler)
           
protected  boolean startConsumer(Consumer consumer)
           
protected  void startRoute(Route route)
           
protected  boolean stopConsumer(Consumer consumer)
           
protected  void stopRoute(Route route)
           
protected  void stopRoute(Route route, long timeout, TimeUnit timeUnit)
           
protected  void suspendRoute(Route route)
           
protected  void suspendRoute(Route route, long timeout, TimeUnit timeUnit)
           
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final transient org.slf4j.Logger log
Constructor Detail

RoutePolicySupport

public RoutePolicySupport()
Method Detail

onInit

public void onInit(Route route)
Description copied from interface: RoutePolicy
Callback invoked when the Route is being initialized

Specified by:
onInit in interface RoutePolicy
Parameters:
route - the route being initialized

onRemove

public void onRemove(Route route)
Description copied from interface: RoutePolicy
Callback invoked when the Route is being removed from CamelContext

Specified by:
onRemove in interface RoutePolicy
Parameters:
route - the route being removed

onStart

public void onStart(Route route)
Description copied from interface: RoutePolicy
Callback invoked when the Route is being started

Specified by:
onStart in interface RoutePolicy
Parameters:
route - the route being started

onStop

public void onStop(Route route)
Description copied from interface: RoutePolicy
Callback invoked when the Route is being stopped

Specified by:
onStop in interface RoutePolicy
Parameters:
route - the route being stopped

onSuspend

public void onSuspend(Route route)
Description copied from interface: RoutePolicy
Callback invoked when the Route is being suspended

Specified by:
onSuspend in interface RoutePolicy
Parameters:
route - the route being suspended

onResume

public void onResume(Route route)
Description copied from interface: RoutePolicy
Callback invoked when the Route is being resumed

Specified by:
onResume in interface RoutePolicy
Parameters:
route - the route being resumed

onExchangeBegin

public void onExchangeBegin(Route route,
                            Exchange exchange)
Description copied from interface: RoutePolicy
Callback invoked when an Exchange is started being routed on the given Route

Specified by:
onExchangeBegin in interface RoutePolicy
Parameters:
route - the route where the exchange started from
exchange - the created exchange

onExchangeDone

public void onExchangeDone(Route route,
                           Exchange exchange)
Description copied from interface: RoutePolicy
Callback invoked when an Exchange is done being routed, where it started from the given Route

Notice this callback is invoked when the Exchange is done and the Route is the route where the Exchange was started. Most often its also the route where the exchange is done. However its possible to route an Exchange to other routes using endpoints such as direct or seda. Bottom line is that the Route parameter may not be the endpoint route and thus why we state its the starting route.

Specified by:
onExchangeDone in interface RoutePolicy
Parameters:
route - the route where the exchange started from
exchange - the created exchange

startConsumer

protected boolean startConsumer(Consumer consumer)
                         throws Exception
Throws:
Exception

stopConsumer

protected boolean stopConsumer(Consumer consumer)
                        throws Exception
Throws:
Exception

startRoute

protected void startRoute(Route route)
                   throws Exception
Throws:
Exception

resumeRoute

protected void resumeRoute(Route route)
                    throws Exception
Throws:
Exception

suspendRoute

protected void suspendRoute(Route route)
                     throws Exception
Throws:
Exception

suspendRoute

protected void suspendRoute(Route route,
                            long timeout,
                            TimeUnit timeUnit)
                     throws Exception
Throws:
Exception

stopRoute

protected void stopRoute(Route route)
                  throws Exception
Throws:
Exception

stopRoute

protected void stopRoute(Route route,
                         long timeout,
                         TimeUnit timeUnit)
                  throws Exception
Throws:
Exception

handleException

protected void handleException(Throwable t)
Handles the given exception using the getExceptionHandler()

Parameters:
t - the exception to handle

doStart

protected void doStart()
                throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: See ServiceSupport.doStop() for more details.

Specified by:
doStart in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStop()

doStop

protected void doStop()
               throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: Camel will invoke this ServiceSupport.doStop() method when the service is being stopped. This method will also be invoked if the service is still in uninitialized state (eg has not been started). The method is always called to allow the service to do custom logic when the service is being stopped, such as when CamelContext is shutting down.

Specified by:
doStop in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStart()

getExceptionHandler

public ExceptionHandler getExceptionHandler()

setExceptionHandler

public void setExceptionHandler(ExceptionHandler exceptionHandler)


Apache CAMEL