Load balancing across a number of endpoints
When you need the ability to distribute a sequence of messages between a predefined set of endpoints, the Load Balancer EIP is a good choice. This is useful for tasks such as web service load balancing at the application level, when a hardware load balancer is not available for use. This EIP allows you to plug in a number of strategies to define how the messages should be distributed amongst the endpoints.
This recipe will show you how to load balance (route) a message across a set of endpoints using a specified policy (for example, round robin).
Getting ready
The Java code for this recipe is located in the org.camelcookbook.routing.loadbalancer
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with loadBalancer
.
How to do it...
The following demonstrates how you might distribute messages using a round-robin strategy.
In the XML DSL, this routing logic is written as follows:
<route> <from uri="direct...