Apache Camel - Dynamically changing throttle values

夙愿已清 提交于 2019-12-06 09:11:43

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

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");

Spring 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>

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

You can change it using JMX eg the management api.

The mbean has JMX attributes to change the values at runtime.

In the upcoming Camel 2.16 release you can easier get hold of the jmx mbeans from java code using

Just that you know the id of the mbean. You can assign ids in the routes, so its using a known id, instead of auto generated. Which btw also makes it easier to find the mbean using pure JMX api.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!