首页 > 解决方案 > 如何修复文本中缺少 ${:错误 - Apache Camel 2.12 到 2.16.4 升级

问题描述

我们正在从 Apache Camel 2.12 升级到 2.16.4,并且遇到了其中一条路线的问题。

Caused by: java.lang.IllegalArgumentException: Missing ${ from the text: file:C:\OnDemandOutput?fileName=RPFPos_L2W.$simple{in.header.accountNum}-${date:now:yyyyMMddHHmmssSSS}.csv
<camelContext xmlns="http://camel.apache.org/schema/spring">

    <propertyPlaceholder id="ignoreId" location="classpath:reformMB.properties"
                               prefixToken="${" suffixToken="}"/>

    <route id="sendNotification">
        <from uri="jms:queue:queue.sendNotification"/>
        <to uri="file:${OnDemand.output.url}?fileName=RPFPos_L2W.$simple{in.header.accountNum}-${date:now:yyyyMMddHHmmssSSS}.csv"/> 
    </route>
</camelContext>

根据文档,这应该有效。有人可以帮我理解什么是错的吗?

根据官方文档,应该可以使用$simple{...}如下方式引用 Camel 的属性:

用 Camels 简单语言冲突 Spring 属性占位符

使用 Spring 桥接占位符时要注意,然后 spring ${} 语法与 Camel 中的 Simple 发生冲突,因此要小心。

例子:

<setHeader headerName="Exchange.FILE_NAME">
  <simple>{{file.rootdir}}/${in.header.CamelFileName}</simple> 
</setHeader>

与 Spring 属性占位符冲突,您应该使用$simple{}Camel 中的 Simple 语言来指示。

<setHeader headerName="Exchange.FILE_NAME">
    <simple>{{file.rootdir}}/$simple{in.header.CamelFileName}</simple
</setHeader>

标签: apache-camel

解决方案


推荐阅读