【问题标题】:How to use sendBodyAndProperty in camel如何在骆驼中使用 sendBodyAndProperty
【发布时间】:2018-10-27 00:09:35
【问题描述】:

我有一个处理器,代码如下

ProducerTemplate.sendBodyAndProperty("direct:endpoint", body, property, propertyValue) 

我需要在下面的 route() 中使用 propertyValue

<route>
    <from uri="direct:endpoint" />
    <to uri="file:/?fileName=${propertyValue}" />
</route>

请指教

【问题讨论】:

标签: apache apache-camel spring-camel


【解决方案1】:

使用生产者方法sendBodyAndProperty,您正在设置交换属性:因此您可以在路由定义中简单地使用Exchange Property EL。

假设你的属性键是“targetFileName”,你可以这样写:

<route>
    <from uri="direct:endpoint" />
    <to uri="file:/?fileName=${exchangeProperty.targetFileName}" />
</route>

【讨论】:

  • 感谢您的帮助!!!动态 uri 不能使用 组件来构建。所以我尝试了收件人列表。像下面的收件人列表(简单(“文件:/?文件名=${exchangeProperty.targetFileName}”));
  • 奇怪.. 我用 Java DSL 和 Camel 版本 2.22.0 进行了测试,它工作正常:to("file:/?fileName=${exchangeProperty.targetFileName}")。它与收件人列表一起使用吗?
  • 无法解析字符串值“file:encrypt/destination?fileName=${exchangeProperty.signFileName}”中的占位符“exchangeProperty.signFileName”
【解决方案2】:

进行以下更改后,它就像魅力一样......谢谢@M.Ricciuti

.to("file:?fileName=$simple{exchangeProperty.targetFileName}") 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-11
    • 2023-04-02
    • 1970-01-01
    相关资源
    最近更新 更多