Weighted

Weighted Load Balancer, with this policy in case of failures the exchange will be tried on the next endpoint.

Options

The Weighted EIP supports 3 options which are listed below:

Name Description Default Type

roundRobin

To enable round robin mode. By default the weighted distribution mode is used. The default value is false.

String

distributionRatio

Required The distribution ratio is a delimited String consisting on integer weights separated by delimiters for example 2,3,5. The distributionRatio must match the number of endpoints and/or processors specified in the load balancer list.

String

distributionRatioDelimiter

Delimiter used to specify the distribution ratio. The default value is ,

,

String

Examples

In this case we are using the header test as correlation expression:

from("direct:start")
    .loadBalance()
    .weighted(false, "4,2,1")
    .to("seda:x", "seda:y", "seda:z");

In XML you’ll have a route like this

<from uri="direct:start"/>
  <loadBalance>
    <weighted roundRobin="false" distributionRatio="4 2 1"/>
    <to uri="seda:x"/>
    <to uri="seda:y"/>
    <to uri="seda:z"/>
  </loadBalance>