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.

Build in load balancing policies

Camel has out of the box the following policies:

Policy

Description

Round Robin

The exchanges is selected in a round robin fashion. This is a well known and classic policy. This spreads the load even.

Random

A random endpoint is selected for each exchange

Sticky

Sticky load balancing using an Expression to calculate a correlation key to perform the sticky load balancing; rather like jsessionid in the web or JMSXGroupID in JMS.

Topic

Topic which sends to all destinations (rather like JMS Topics)

Failover

Camel 2.0: In case of failures the exchange is tried on the next endpoint.

Round Robin

Using the Fluent Builders

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

...

So the above example will load balance requests from direct:start to one of the available 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

Build in load balancing policies

Camel has out of the box the following policies:

...

Policy

...

Description

...

Round Robin

...

The exchanges is selected in a round robin fashion. This is a well known and classic policy. This spreads the load even.

...

Random

...

A random endpoint is selected for each exchange

...

Sticky

...

Sticky load balancing using an Expression to calculate a correlation key to perform the sticky load balancing; rather like jsessionid in the web or JMSXGroupID in JMS.

...

Topic

...

Topic which sends to all destinations (rather like JMS Topics)

Failover

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.

Here is a sample to failover only if a IOException related exception was thrown:

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

...

Failover

...

Include Page
CAMEL:Using This Pattern
CAMEL:Using This Pattern