gpt4 book ai didi

Java Camel 路由永远不会到达 other 语句

转载 作者:行者123 更新时间:2023-12-02 04:21:35 25 4
gpt4 key购买 nike

我正在创建一项服务,根据文件名将文件传输到新位置。问题是,即使第一个when为假(文件名不以“START”开头),第二个otherwise语句也永远不会到达。另外, from uri 有 delete=true 选项,也许这会影响一些东西。结果是文件被删除了。

        <route id="outgoing" errorHandlerRef="outgoingDeadLetterErrorHandler">
<from uri="OutgoingSource"/>

<choice>
<when>
<simple>${file:name} starts with 'START'</simple>

<convertBodyTo type="java.lang.String"/>
<choice>
<when>
<xpath>/File/Header/@x = 'X'</xpath>
<to ref="OutgoingErrorDestination"/>
</when>
<when>
<xpath>/Header/@y = 'Y'</xpath>
<to ref="OutgoingDestination"/>
</when>
<otherwise>
<to ref="OutgoingErrorDestination"/>
</otherwise>
</choice>
</when>
<otherwise>
<to ref="OutgoingErrorDestination"/>
</otherwise>
</choice>
</route>

最佳答案

file:name 相对于起始目录(即 file:name = test\hello.txt)

如果您只想测试文件名,您应该使用 file:onlyname.noext

<simple>${file:onlyname.noext} starts with 'START'</simple>

关于Java Camel 路由永远不会到达 other 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56633925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com