如何使用骆驼在运行时改变处理器的性能? [英] How to change Processor properties during runtime using Camel?

查看:181
本文介绍了如何使用骆驼在运行时改变处理器的性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个骆驼路线用Java编写的DSL这样的定义:

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

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

本使用这限制了消息流,以每秒200消息的节流连接我的两个端点。

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

我在寻找一种方式在运行时改变maximumRequestCount /秒。
所以,我需要以某种方式获得的节流实例,被调用,改变属性。

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.

我如何访问节流?

推荐答案

好吧,我想通了我自己......

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.

这篇关于如何使用骆驼在运行时改变处理器的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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