【发布时间】:2021-03-17 13:19:22
【问题描述】:
我有路线
String XYZ = "xyz";
from(URL_A)
.bean(PropertiesSetterBean.class)
.to("${property." + XYZ + "}")
PropertiesSetterBean 在哪里:
@Component
class PropertiesSetterBean {
public void copyProperties(@Headers Map<String, Object> headers, @ExchangeProperties Map<String, Object> properties) {
properties.put("xyz", "direct:test")
}
}
我得到的错误:
在以下位置创建路由 route1 失败:>>> DynamicTo[${property.xyz}]
看起来bean 没有被执行。
我使用骆驼:3.7.3,spring-boot:2.4.3,java:11
我做的步骤:
- 我阅读了迁移指南
- 查看了 GitHub 上可用的代码 sn-ps
- 搜索 StackOverflow
- 与同事交谈
我查看了类似的issue。
而且,我仍然无法对问题进行分类。
我做错了什么?
更新 1
我添加了处理器:
.process(exchange -> {
System.out.println("This is my property: " + exchange.getProperty("xyz"));
})
它有效。与此同时,我仍然无法在 Camel 中使用 simple DSL 检索此属性。
【问题讨论】:
-
不应该
properties.put("xyz", "direct:test")是properties.put("property.xyz", "direct:test")? -
@Lino,我不知道在 Camel 3.7.3 中应该是什么样子,但我发布的语法在 Camel 2.X.X 中是有效的
标签: java spring-boot apache-camel migration apache-camel-3