Apache Camel-动态更改油门值 [英] Apache Camel - Dynamically changing throttle values

查看:146
本文介绍了Apache Camel-动态更改油门值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以通过使用Throttler处理器实例或使用Apache Camel中的节流元素来动态更改maxRequestsPerPeriod的示例吗? (参考-如何在运行时使用Camel更改处理器属性?)

Can anyone please give a sample on how to dynamically change the maxRequestsPerPeriod by using a Throttler processor instance or using a throttle element in Apache Camel ? (Reference - How to change Processor properties during runtime using Camel?)

我们不能将Expression与标头一起使用,因为如果没有标头,那么节流阀将使用旧值.我们需要的是,在基于某种条件的Bean中,我们必须更新油门值,以便在下一次更新之前使用它.在我们的情况下,我们不能为此目的使用消息头.

We cannot use Expression with header because if the header is absent then the Throttler uses the old value. What we need is, in a bean based on some condition we have to update the throttle value so that it will be used until next update. In our case, we cannot use message header for this purpose.

我们如何导航路线中的运行时处理器并找到可动态更改的Throttler?请提供样品帮助.

How can we navigate the runtime processors in the route and find the Throttler to change it dynamically? Please help with a sample.

谢谢.

推荐答案

感谢Claus ..我们将在即将发布的Camel 2.16版本中检查jmx mbeans.

Thanks Claus..We will check jmx mbeans in upcoming Camel 2.16 release.

现在以下解决方案适用于 Camel 2.15.2 :

Now the following solution worked for us with Camel 2.15.2 :

Java DSL:

from("direct:start")
  .routeId("throttleroute")
  .throttle(ExpressionBuilder.beanExpression("throttleBean","getThrottle"))
  .timePeriodMillis(2000)
  .to("jms:test.MyQueue")
  .beanRef("throttleBean", "receiveData");

春季DSL:

<route id="throttleroute">
    <from uri="direct:start" />
        <throttle timePeriodMillis="2000">
            <method ref="throttleBean" method="getThrottle" />
            <to uri="jms:test.MyQueue" />
        </throttle>
    <to uri="bean:throttleBean?method=receiveData" />
</route>

在这里,油门Bean.getThrottle()方法将具有逻辑来动态生成和返回所需的油门值.

Here throttleBean.getThrottle() method will be having the logic to generate and return the required throttle value dynamically.

这篇关于Apache Camel-动态更改油门值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆