骆驼重定向到另一条节流路线

时间:2015-05-25 04:12:36

标签: apache-camel throttling

我有一条骆驼路线,在收到大量信息时会受到限制。假设我定义的最大交换是每2秒3个,并且路由收到的超过我想要将这些消息重定向到其他负载均衡器路由的限制。有人可以帮助我如何实现它吗?

1 个答案:

答案 0 :(得分:0)

如果我理解你的问题,你想要限制收到的消息,然后将这些消息权衡到不同的路由或系统。

from("SomethingSendingMeMessages")
    .throttle(3)
    .loadbalance().roundRobin()
        .to("place1", "place2", "place3")
    .end();

如果你需要将限制路由发送到包含loadbalancer的第二条路由,你可以这样做:

from("SomethingSendingMeMessages")
    .throttle(3)
    .to("direct:mySecondRoute");

from("direct:mySecondRoute")
    .loadbalance().roundRobin()
        .to("place1", "place2", "place3")
    .end();

您可以探索的另一个选项是在负载均衡器之后限制以控制每个单独路线的方法。

from("SomethingSendingMeMessages")
    .loadbalance().roundRobin()
        .to("direct:place1", "direct:place2")
    .end();

from("direct:place1")
    .throttle(3)
    .to("myOtherWork");

from("direct:place2")
    .throttle(3)
    .to("myOtherWork");
相关问题