...
Available as of Camel 2.0
The failover
load balancer is capable of trying the next processor in case an Exchange failed with an exception
during processing.
You can configure the failover
with a list of specific exception to only failover. If you do not specify any exceptions it will failover over any exceptions. It uses the same strategy for matching exceptions as the Exception Clause does for the onException.
Note | ||
---|---|---|
| ||
The failover load balancer requires you have enabled Camel Error Handler to use redelivery. By default Camel does not do this. |
Here is a sample to failover only if a IOException
related exception was thrown:
...
You can specify multiple exceptions to failover as the option is varargs, for instance:
Code Block | ||||
---|---|---|---|---|
| ||||
// enable redelivery so failover can react errorHandler(defaultErrorHandler().maximumRedeliveries(5)); from("direct:foo"). loadBalance().failover(IOException.class, MyOtherException.class) .to("direct:a", "direct:b"); |
...
Failover can also be used from Spring DSL and you configure it as:
Code Block | ||||
---|---|---|---|---|
| ||||
<route errorHandlerRef="myErrorHandler"> <from uri="direct:foo"/> <loadBalance> <failover> <exception>java.io.IOException</exception> <exception>com.mycompany.MyOtherException</exception> </failover> <to uri="direct:a"/> <to uri="direct:b"/> </loadBalance> </route> |
Include Page | ||||
---|---|---|---|---|
|