为什么 属性 在 Camel 3.7.3 中没有得到正确的评估?

Why property doesn't get evaluated correctly in Camel 3.7.3?

我有路线

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")
  }
}

我得到的错误:

Failed to create route route1 at: >>> DynamicTo[${property.xyz}] <<< in route: Route(route1)[From[seda:inEvents?concurrentCon... because of Property with key [property.xyz] not found in properties from text: ${property.xyz}

看起来bean没有执行。

我用的是camel:3.7.3, spring-boot:2.4.3, java:11

我执行的步骤:

我调查了一个类似的

而且,我仍然无法对问题进行分类。

我做错了什么?

更新 1

我添加了处理器:

.process(exchange -> {
  System.out.println("This is my property: " + exchange.getProperty("xyz"));
})

有效。与此同时,我仍然无法在 Camel 中使用 simple DSL 检索此 属性。

经过几个小时的搜索没有结果,我遇到了一个 old post

要访问 属性,我需要使用 "${exchangeProperty." + XYZ + "}"

注:

  • 它适用于 Camel 2.X.X,因此请注意此更改。
  • 如果 Spring 和 Camel 占位符之间存在冲突,请使用 $simple 而不是 $
  • 在 Camel 3.X.X 中,您需要检查您的属性所在的位置并将它们重新指向 exchangeProperty