use of org.apache.camel.processor.loadbalancer.WeightedRoundRobinLoadBalancer in project camel by apache.
the class WeightedLoadBalancerDefinition method createLoadBalancer.
@Override
protected LoadBalancer createLoadBalancer(RouteContext routeContext) {
WeightedLoadBalancer loadBalancer;
List<Integer> distributionRatioList = new ArrayList<Integer>();
try {
String[] ratios = distributionRatio.split(getDistributionRatioDelimiter());
for (String ratio : ratios) {
distributionRatioList.add(new Integer(ratio.trim()));
}
boolean isRoundRobin = getRoundRobin() != null && getRoundRobin();
if (isRoundRobin) {
loadBalancer = new WeightedRoundRobinLoadBalancer(distributionRatioList);
} else {
loadBalancer = new WeightedRandomLoadBalancer(distributionRatioList);
}
} catch (Exception e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
return loadBalancer;
}
Aggregations