Camel provides lots of solution for different-different problems, Camel Load Balancer EIP solution is one of them. This is one of best option when we need to distribute the messages between the predefined set of endpoints using a different-different load balancing policies.

Here are some useful policies:

RoundRobin policy : Here is sample example using Java DSL:

In above example, we are distributing messaging using roundRobin load balancing policy. In case of Round Robin strategy 1 message will go to mock:route1 endpoint then the 2nd message will go to mock:route2 endpoint then 3rd one will go to mock:route1 and so on. basically, it holds the state of which endpoint to use next time.

Failover policy: Another policy name is Failover, it is a good choice to use when we need to try next endpoint if the first one fails during an exception

Here failover is taking 3 parameters
1st param is max retry attempts
2nd whether the current route’s error handler should come into play
3rd round-robin strategy

Random policy: The random strategy behaves as the name would suggest. Here is a example of random load balancing.

In the above example of random policy, message randomly will go to any one of the endpoint.

Sticky policy: This strategy is similar to roundRobin however, all messages that share the same result for a provided Expression will be routed to the same endpoint. Implements a sticky load balancer using an Expression to calculate a correlation key to perform the sticky load balancing; rather like jsessionid in the web or JMSXGroupID in JMS.