【问题标题】:how to set id of camel processor or other route ingredients如何设置骆驼处理器或其他路线成分的ID
【发布时间】:2015-04-19 03:54:36
【问题描述】:

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

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

更新

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

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

【问题讨论】:

  • 这样设置它们有帮助吗:<bean id="myProcessor" class="com.acme.MyProcessor"/>

标签: apache-camel


【解决方案1】:

如果使用 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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 2013-08-13
    • 2014-11-29
    • 2020-05-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多