【问题标题】:How to set a header to a value from a properties file in Apache Camel如何将标头设置为 Apache Camel 中属性文件中的值
【发布时间】:2012-12-26 09:32:13
【问题描述】:

是否可以使用骆驼属性组件将消息头设置为从属性文件中读取的值?我可以将此类属性设置为 URI 选项,但无法将它们设置为标头值。

我需要这样的东西:

<camel:setHeader headerName="actionId">
    <camel:constant>{{onus.transPosting.RtSFailed}}</camel:constant>
</camel:setHeader>

其中onus.transPosting.RtSFailed 是在使用骆驼属性组件导入的文件上设置的属性键。

注意:我使用的是 Apache Camel 2.10.1

更新

按照this discussion 的建议使用&lt;propertyPlaceholder&gt; 不起作用,它会导致异常:

Caused by: org.apache.camel.language.simple.types.SimpleParserException: Unknown function: onus.transPosting.RtSFailed

【问题讨论】:

  • &lt;simple&gt;${onus.transPosting.RtsFailed}&lt;/simple&gt; 不起作用? (就像没有使用 Apache Camel 的经验一样好)
  • 查看此讨论:camel.465427.n5.nabble.com/…
  • 感谢康斯坦丁,请检查我在帖子上的更新

标签: java apache-camel


【解决方案1】:

是的,你可以,使用具有属性函数的简单语言:http://camel.apache.org/simple

<camel:setHeader headerName="actionId">
    <camel:simple>${properties:onus.transPosting.RtSFailed}</camel:simple>
</camel:setHeader>

虽然我认为我们已经在最新的 Camel 版本中修复了 也将解析属性占位符。

【讨论】:

  • 我的错,我应该提到我正在使用的版本,我相应地更新了问题。无论如何,简单的属性功能对我有用。非常感谢:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-23
  • 1970-01-01
相关资源
最近更新 更多