如何设置骆驼处理器或其他路线成分的ID

how to set id of camel processor or other route ingredients

Camel 自动为处理器和其他东西生成 ID (processor1..processor25)。有没有办法设置这个名字?我们需要通过 jmx 识别某些处理器以获取遥测数据。

我要设置的名称是通过属性给出的 - 它们在开始时已知。所以我需要在定义路由时或在处理器中设置它们(名称通过处理器构造函数给出,字符串也用于处理)。

更新

示例:对于路线 from("some:where").process(myProcessor).to(no:where) 我需要设置 myProcessor 的 ID。我需要 "ExchangesTotal" 和来自某些处理器的其他东西

我需要 Java DSL 中的解决方案。

如果使用 xml 则使用 id 属性。

<to id="foo" uri="seda:foo"/>

如果使用 java 代码,则使用 .id

.to("seda:bar").id("foo");

还有一个特别的地方是设置路由的id,你必须使用它.routeId

from("xxx").routeId("id of the route")
   .to("xxx")

所以你的例子应该是

from("some:where").process(myProcessor).id("theIdOfTheProcessorYouWant").to(no:where)