The changes are primarily in 2 areas
of specified load balancing processors, I had opted to use best effort load balancing
at runtime along with log warnings. In Camel 2.6, this behavior has now been
changed to throw an exception during route startup to indicate that the
distributionRatio does not match the number of processors.
a> http://opensourceknowledge.blogspot.com/2010/10/added-support-for-weighted-round-robin.html
b> Camel Documentation (http://camel.apache.org/load-balancer.html).
I have modified this in Camel 2.6 based on Claus' recommendation and made
an input of integer weights separated by a delimiter. The delimiter can also be
influenced using distributionRatioDelimiter String (the default delimiter being ",").
Given below are examples of how this simplifies the DSL for Camel 2.6
public void testRoundRobin() throws Exception { x.expectedMessageCount(5); y.expectedMessageCount(2); z.expectedMessageCount(1); context.addRoutes(new RouteBuilder() { public void configure() { // START SNIPPET: example from("direct:start").loadBalance(). weighted(true, "4,2,1").to("mock:x", "mock:y", "mock:z"); // END SNIPPET: example } }); context.start(); sendMessages(1, 2, 3, 4, 5, 6, 7, 8); assertMockEndpointsSatisfied(); x.expectedBodiesReceived(1, 4, 6, 7, 8); y.expectedBodiesReceived(2, 5); z.expectedBodiesReceived(3); }
For Spring XML examples, please check out the following links
weightedRoundRobinLoadBalance.xml
weightedRandomLoadBalance.xml
No comments:
Post a Comment