【问题标题】:Constant and placeholder in Apache CamelApache Camel 中的常量和占位符
【发布时间】:2021-07-16 10:47:26
【问题描述】:

我如何发送这个字符串 "field1": "header: ${fesb.a broker.}\n const: "{{CONST}} " 而不进行任何转换,包括 {{VAR}}。

此代码导致在此处插入 VAR 属性“{{VAR}}”。

<setBody test:component="SetBodyEndpoint">
                <constant><![CDATA["{
  "field1": "header: ${testVar}\n const: "{{VAR}}"
}"]]></constant>
 </setBody>

【问题讨论】:

    标签: apache-camel


    【解决方案1】:

    我猜占位符在编译时会被解析,所以你不能在你的路由中保持不变,即使在constant 表达式中也是如此。
    作为一种解决方法,您可以将原始字符串放入文件中,然后在路由中读取它,例如

    <setBody>
        <simple resultType="java.io.File">path/to/file/rawString.txt</simple>
    </setBody>
    <convertBodyTo type="java.lang.String"/>
    

    【讨论】:

    • 感谢解答,通过文件的解决方案很好,但我不喜欢每次处理都读取文件
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-08
    • 1970-01-01
    • 1970-01-01
    • 2013-02-21
    • 1970-01-01
    相关资源
    最近更新 更多