如何设置骆驼处理器的ID或其他路线成分 [英] how to set id of camel processor or other route ingredients
问题描述
Camel自动为处理器和其他内容(processor1..processor25)生成ID.有没有办法设置这个名字?我们需要通过jmx识别某些处理器以获取遥测数据.
Camel automatically generates id for processors and other stuff (processor1..processor25). Is there a way to set this name? We need to identify certain processors via jmx to get telemetry data.
我要设置的名称是通过属性给出的-在开始时就知道了.因此,我需要在定义路由时或在处理器内进行设置(名称由处理器构造函数指定,字符串也用于处理).
The names I want to set are given via properties - they are known on start time. So I need to set them when route is defined or within the processor (name is given via processors constructor, the string is also used for processing).
更新
示例:对于路由from("some:where").process(myProcessor).to(no:where)
,我需要设置myProcessor的ID.我需要来自某些处理器的"ExchangesTotal"和其他内容
Example: for a route from("some:where").process(myProcessor).to(no:where)
i need to set the id of myProcessor. I need "ExchangesTotal" and other stuff from certain processors
我需要Java DSL解决方案.
I need a solution in Java DSL.
推荐答案
如果使用xml,则使用id属性.
If using xml then use the id attribute.
<to id="foo" uri="seda:foo"/>
如果使用Java代码,请使用.id
And if using java code, then use .id
.to("seda:bar").id("foo");
其中一项特殊功能是设置路线的ID,您必须使用.routeId
And one special is to set the id of the route, which you must use .routeId
from("xxx").routeId("id of the route")
.to("xxx")
所以你的例子应该是
from("some:where").process(myProcessor).id("theIdOfTheProcessorYouWant").to(no:where)
这篇关于如何设置骆驼处理器的ID或其他路线成分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!