我有一个Camel用 Java DSL 编写的路由定义如下:
from(myEndpoint)
.throttle(200)
.to(myOtherEndpoint);
这使用 Throttler 连接我的两个端点,该 Throttler 将消息流限制为每秒 200 条消息。
我正在寻找一种在运行时更改最大请求计数/秒的方法。 所以我需要以某种方式到达被调用的 Throttler 实例并更改属性。
如何访问 Throttler?
最佳答案
好吧,我自己想出来了......
您需要自己定义 Throttler 实例。
Throttler throttler = new Throttler(null, 200);
然后你可以像这样在你的路由中使用它,因为 Throttler 实现了 Processor 接口(interface):
from(myEndpoint)
.process(throttler)
.to(myOtherEndpoint);
您可以随时更改 throttle 的属性。
关于java - 如何使用 Camel 在运行时更改处理器属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1131107/