骆驼中的节流请求不起作用
Throttle requests in camel not working
下面是我的基础 groovy 路线 class 部署为基础框架的 3 条路线。
from("jms:queue:EndPoint1?concurrentConsumers=100")
.routePolicyRef("myPolicy")
.transacted()
.log("Recieved From Endpoint1")
/*.to("log:Recieved From Endpoint1?groupSize=100")*/
.to("CommonEndpoint");
from("jms:queue:EndPoint2?concurrentConsumers=50")
.rootPolicyRef("myPolicy")
/*.to("log:Recieved From Endpoint2?groupSize=100")*/
.log("Recieved From Endpoint2")
.to("CommonEndpoint");
from("CommonEndpoint")
.delay(50)
/*.to("log:Delayed?groupSize=100")*/
.log("Delayed");
下面是我在引用基础框架的包中创建的计时器路由。
from("timer://Timer1?fixedRate=true&period=60000")
.to("jms:queue:EndPoint1");
和
from("timer://Timer2?fixedRate=true&period=60000")
.to("jms:queue:EndPoint2");
它不断地向 Endpoint1 和 Enpoint2 发送定时器消息,Enpoint2 都向 commonendpoint 发送消息。我的 ThrottlingInflightRoutePolicy 定义如下。
<bean id="myPolicy" class="org.apache.camel.impl.ThrottlingInflightRoutePolicy">
<property name="scope" value="Context"/>
<property name="maxInflightExchanges" value="20"/>
<property name="resumePercentOfMax" value="10"/>
<property name="loggingLevel" value="WARN"/>
</bean>
在检查日志时,我可以简单地看到计时器的日志跟踪。我不明白如何在检查日志时限制请求。我这里有什么遗漏吗??在我的代码中应该做什么来测试节流....?
我不确定如何实施您已设置的 ThrottlingInflightPolicy,但您可以实施这样的路由来实现您的目标。
from("jms:queue:EndPoint1?concurrentConsumers=20")
.throttle(10)
.to("Other_Logic_Or_Routing");
备注:
maxInflightExchanges 可以通过简单地将 concurrentConsumers 降低到 20 来控制
Throttle 组件可以确保您的消息速率不超过限制。
有很多方法可以为您的路线配置油门,所以请根据文档查找您想要配置的内容。我的示例将路由限制为每秒处理 10 条消息。
http://camel.apache.org/throttler.html
下面是我的基础 groovy 路线 class 部署为基础框架的 3 条路线。
from("jms:queue:EndPoint1?concurrentConsumers=100")
.routePolicyRef("myPolicy")
.transacted()
.log("Recieved From Endpoint1")
/*.to("log:Recieved From Endpoint1?groupSize=100")*/
.to("CommonEndpoint");
from("jms:queue:EndPoint2?concurrentConsumers=50")
.rootPolicyRef("myPolicy")
/*.to("log:Recieved From Endpoint2?groupSize=100")*/
.log("Recieved From Endpoint2")
.to("CommonEndpoint");
from("CommonEndpoint")
.delay(50)
/*.to("log:Delayed?groupSize=100")*/
.log("Delayed");
下面是我在引用基础框架的包中创建的计时器路由。
from("timer://Timer1?fixedRate=true&period=60000")
.to("jms:queue:EndPoint1");
和
from("timer://Timer2?fixedRate=true&period=60000")
.to("jms:queue:EndPoint2");
它不断地向 Endpoint1 和 Enpoint2 发送定时器消息,Enpoint2 都向 commonendpoint 发送消息。我的 ThrottlingInflightRoutePolicy 定义如下。
<bean id="myPolicy" class="org.apache.camel.impl.ThrottlingInflightRoutePolicy">
<property name="scope" value="Context"/>
<property name="maxInflightExchanges" value="20"/>
<property name="resumePercentOfMax" value="10"/>
<property name="loggingLevel" value="WARN"/>
</bean>
在检查日志时,我可以简单地看到计时器的日志跟踪。我不明白如何在检查日志时限制请求。我这里有什么遗漏吗??在我的代码中应该做什么来测试节流....?
我不确定如何实施您已设置的 ThrottlingInflightPolicy,但您可以实施这样的路由来实现您的目标。
from("jms:queue:EndPoint1?concurrentConsumers=20")
.throttle(10)
.to("Other_Logic_Or_Routing");
备注: maxInflightExchanges 可以通过简单地将 concurrentConsumers 降低到 20 来控制 Throttle 组件可以确保您的消息速率不超过限制。
有很多方法可以为您的路线配置油门,所以请根据文档查找您想要配置的内容。我的示例将路由限制为每秒处理 10 条消息。 http://camel.apache.org/throttler.html