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

der*_*itz 2 apache-camel

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

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

更新

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

我需要一个Java DSL解决方案.

Cla*_*sen 14

如果使用xml,则使用id属性.

<to id="foo" uri="seda:foo"/>
Run Code Online (Sandbox Code Playgroud)

如果使用java代码,那么使用 .id

.to("seda:bar").id("foo");
Run Code Online (Sandbox Code Playgroud)

一个特殊的是设置路径的ID,您必须使用它 .routeId

from("xxx").routeId("id of the route")
   .to("xxx")
Run Code Online (Sandbox Code Playgroud)

所以你的榜样应该是

from("some:where").process(myProcessor).id("theIdOfTheProcessorYouWant").to(no:where)
Run Code Online (Sandbox Code Playgroud)