如何设置骆驼处理器或其他路线成分的ID [英] how to set id of camel processor or other route ingredients

查看:25
本文介绍了如何设置骆驼处理器或其他路线成分的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Camel 自动为处理器和其他东西生成 id (processor1..processor25).有没有办法设置这个名字?我们需要通过 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屋!

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