public class FailOverLoadBalancer extends LoadBalancerSupport implements Traceable, CamelContextAware
Pipeline in the async variation
as the failover load balancer is a specialized pipeline. So the trick is to keep doing the same as the
pipeline to ensure it works the same and the async routing engine is flawless.logshutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending| Constructor and Description |
|---|
FailOverLoadBalancer() |
FailOverLoadBalancer(List<Class<?>> exceptions) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
CamelContext |
getCamelContext()
Get the
CamelContext |
ExceptionFailureStatistics |
getExceptionFailureStatistics() |
List<Class<?>> |
getExceptions() |
int |
getLastGoodIndex() |
int |
getMaximumFailoverAttempts() |
String |
getTraceLabel()
Gets the trace label used for logging when tracing is enabled.
|
boolean |
isRoundRobin() |
boolean |
isRunAllowed()
Helper methods so the service knows if it should keep running.
|
boolean |
isSticky() |
protected Exchange |
prepareExchangeForFailover(Exchange exchange)
Prepares the exchange for failover
|
boolean |
process(Exchange exchange,
AsyncCallback callback)
Processes the message exchange.
|
void |
reset() |
void |
setCamelContext(CamelContext camelContext)
Injects the
CamelContext |
void |
setMaximumFailoverAttempts(int maximumFailoverAttempts) |
void |
setRoundRobin(boolean roundRobin) |
void |
setSticky(boolean sticky) |
protected boolean |
shouldFailOver(Exchange exchange)
Should the given failed Exchange failover?
|
String |
toString() |
addProcessor, doShutdown, getId, getProcessors, hasNext, next, process, removeProcessor, setIddoResume, doSuspend, getStatus, getVersion, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendpublic FailOverLoadBalancer()
public FailOverLoadBalancer(List<Class<?>> exceptions)
public CamelContext getCamelContext()
CamelContextAwareCamelContextgetCamelContext in interface CamelContextAwarepublic void setCamelContext(CamelContext camelContext)
CamelContextAwareCamelContextsetCamelContext in interface CamelContextAwarecamelContext - the Camel contextpublic int getLastGoodIndex()
public List<Class<?>> getExceptions()
public boolean isRoundRobin()
public void setRoundRobin(boolean roundRobin)
public boolean isSticky()
public void setSticky(boolean sticky)
public int getMaximumFailoverAttempts()
public void setMaximumFailoverAttempts(int maximumFailoverAttempts)
protected boolean shouldFailOver(Exchange exchange)
exchange - the exchange that failedpublic boolean isRunAllowed()
StatefulServiceisRunAllowed in interface StatefulServiceisRunAllowed in class ServiceSupportpublic boolean process(Exchange exchange, AsyncCallback callback)
AsyncProcessorProcessor.process(org.apache.camel.Exchange), but the caller supports having the exchange asynchronously processed.
If there was a failure processing then the caused Exception would be set on the Exchange.process in interface AsyncProcessorexchange - the message exchangecallback - the AsyncCallback will be invoked when the processing of the exchange is completed.
If the exchange is completed synchronously, then the callback is also invoked synchronously.
The callback should therefore be careful of starting recursive loop.protected Exchange prepareExchangeForFailover(Exchange exchange)
exchange - the exchangepublic String getTraceLabel()
TraceablegetTraceLabel in interface Traceablepublic ExceptionFailureStatistics getExceptionFailureStatistics()
public void reset()
protected void doStart() throws Exception
ServiceSupportServiceSupport.doStop() for more details.doStart in class LoadBalancerSupportExceptionServiceSupport.doStop()protected void doStop() throws Exception
ServiceSupportServiceSupport.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.doStop in class LoadBalancerSupportExceptionServiceSupport.doStart()Apache Camel