java - Java骆驼路线永远不会达到否则声明
问题描述
我正在创建一个基于文件名将文件传输到新位置的服务。问题是即使第一个 when 为假(文件名不以“START”开头),也永远不会到达第二个 else 语句。此外, 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>
推荐阅读
- excel - 使用 Excel VBA 解析来自 ITIS 的 XML 响应
- python - Pygame无响应显示
- java - 有没有办法使用 Java 11 的 HttpClient 从 HTTP 1.1 响应的状态行中获取原因短语?
- django - 当我尝试使用英语以外的任何语言进行搜索时出现服务器错误 (500)
- isabelle - 如何在 Isabelle 中证明“(⋀x. PROP ?P x) ⟹ PROP ?P ?x”?
- java - 如何在 Spring Boot War 中包含特定的 applicaction.properties
- python - 如何撤消 QAbstractTableModel 中的更改?
- postgresql - 如何在 jsonb 字段属性上使用 group_by 查询最新条目
- r - 如何从面板数据中按年份获取 Stargazer 汇总统计数据
- ruby - 为什么 Pathname.rmtree 在 Signal.trap('EXIT') 上失败