Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Load Balancer Pattern allows you to delegate to one of a number of endpoints using a variety of different load balancing policies.

Using the Fluent Builders

Wiki Markup
{snippet:id=example|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoadBalanceTest.java}

*Using the Spring configuration

Wiki Markup
{snippet:id=example|lang=xml|url=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/loadBalance.xml}
Code Block

from("cxf:bean:routerEndpoint").
  loadBalance().roundRobin().
  to("cxf:bean:serviceEndpoint1", "cxf:bean:serviceEndpoint2", "cxf:bean:serviceEndpoint3");

So the above example will load balance requests from cxfdirect:bean:routerEndpointstart to one of the available serviceEndpoint mock endpoint instances, in this case using a round robbin policy.
For further examples of this pattern in use you could look at the junit test case

...