How to change Processor properties during runtime using Camel?

隐身守侯 提交于 2019-12-24 12:16:06

问题


I have a Camel Route Definition written in Java DSL like this:

from(myEndpoint) 
.throttle(200)
.to(myOtherEndpoint);

This connects my two endpoints using a Throttler which limits the message flow to 200 messages per second.

I'm looking for a way to change the maximumRequestCount / second during runtime. So I need to somehow get to the Throttler instance which is called and change the property.

How can I access the Throttler?


回答1:


Ok, I figured it out by myself ...

You need to define your Throttler instance yourself.

Throttler throttler = new Throttler(null, 200);

Then you can use it in your routes like this, because Throttler implements the Processor interface:

from(myEndpoint) 
.process(throttler)
.to(myOtherEndpoint);

Any time you like you can change the properties of the throttler.




回答2:


Yeah that is a neat solution.

In Camel 2.0 you can now navigate the runtime processors in the route and thus find any Throttlers and then be able to change it dynamically.

But we are also working on improving the JMX in Camel 2.1 so you can change throttler/delayer and the likes from JMX.

And maybe also improve the Navigate API so you can find in a one liner, eg maybe lookup by id if you provide an id in the route. Or by types so you can filter and only get the Throttlers etc.



来源:https://stackoverflow.com/questions/1131107/how-to-change-processor-properties-during-runtime-using-camel

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