org.apache.camel.processor.loadbalancer
Class FailOverLoadBalancer
java.lang.Object
org.apache.camel.impl.ServiceSupport
org.apache.camel.processor.loadbalancer.LoadBalancerSupport
org.apache.camel.processor.loadbalancer.FailOverLoadBalancer
- All Implemented Interfaces:
- AsyncProcessor, Navigate<Processor>, Processor, LoadBalancer, Traceable, Service, ShutdownableService
public class FailOverLoadBalancer
- extends LoadBalancerSupport
- implements Traceable
This FailOverLoadBalancer will failover to use next processor when an exception occurred
This implementation mirrors the logic from the 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.
| Methods inherited from class org.apache.camel.impl.ServiceSupport |
addChildService, doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, start, stop, suspend |
FailOverLoadBalancer
public FailOverLoadBalancer()
FailOverLoadBalancer
public FailOverLoadBalancer(List<Class<?>> exceptions)
getExceptions
public List<Class<?>> getExceptions()
isRoundRobin
public boolean isRoundRobin()
setRoundRobin
public void setRoundRobin(boolean roundRobin)
getMaximumFailoverAttempts
public int getMaximumFailoverAttempts()
setMaximumFailoverAttempts
public void setMaximumFailoverAttempts(int maximumFailoverAttempts)
shouldFailOver
protected boolean shouldFailOver(Exchange exchange)
- Should the given failed Exchange failover?
- Parameters:
exchange - the exchange that failed
- Returns:
- true to failover
process
public boolean process(Exchange exchange,
AsyncCallback callback)
- Description copied from interface:
AsyncProcessor
- Processes the message exchange.
Similar to
Processor.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.
- Specified by:
process in interface AsyncProcessor
- Parameters:
exchange - 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.
- Returns:
- (doneSync) true to continue execute synchronously, false to continue being executed asynchronously
- See Also:
AsyncProcessorHelper.process(AsyncProcessor, Exchange, AsyncCallback)
prepareExchangeForFailover
protected void prepareExchangeForFailover(Exchange exchange)
- Prepares the exchange for failover
- Parameters:
exchange - the exchange
toString
public String toString()
- Overrides:
toString in class Object
getTraceLabel
public String getTraceLabel()
- Description copied from interface:
Traceable
- Gets the trace label used for logging when tracing is enabled.
The label should be short and precise.
- Specified by:
getTraceLabel in interface Traceable
- Returns:
- the label
Apache CAMEL