concept failover in category camel

appears as: failover, failover, The failover
Camel in Action

This is an excerpt from Manning's book Camel in Action.

Load balancing is often used to implement failover—the continuation of a service after a failure. The Camel failover load balancer detects the failure when an exception occurs and reacts by letting the next processor take over processing the message.

Given the following route snippet, the failover will always start by sending the messages to the first processor (direct:a) and only in the case of a failure will it let the next processor (direct:b) take over:

Listing 11.14  Route using error handling with failover to FTP
errorHandler(defaultErrorHandler() .maximumRedeliveries(5).redeliveryDelay(10000)); onException(IOException.class).maximumRedeliveries(3)     #1 .handled(true) .to("ftp://gear@ftp.rider.com?password=secret"); from("file:/rider/files/upload?delay=15m") .to("http://rider.com/upload?user=gear&password=secret"); #1 Exception policy

If you copy a bunch of files to the target/inbox directory, only the master node will pick up and process the files. While the files are being processed, you can try to shut down or kill the master, which should trigger a failover. The slave node then becomes the master and starts processing the files.