HOW:Apache Camel、Regex 匹配文件 [英] HOW: Apache Camel, Regex match files
问题描述
我正在尝试让骆驼做一些文件操作并将它们传递给 activeMQ 代理,我从一个最近退出的人那里接手了这个项目.
im experimenting in getting camel to do some file operations and pass them through the activeMQ broker, ive taken this project over from a guy who recently quit.
到目前为止我得到了什么:
what ive got so far:
<route id="SVLFTPCOPY">
<from uri="sftp://*****:*******@********/srv/test/?fileName=*2280.xls&noop=true&idempotent=false"/>
<to uri="file:/srv/data/test/destination/"/>
<to uri="activemq:queue:svl.ftp.copy"/>
</route>
它可以运行路由而不会抛出任何错误,但仍然不会将文件复制到本地文件.
it works to the point where it runs the route without throwing any errors, but still doesnt copy the file to the local file.
有什么想法吗?.
推荐答案
是的,如果您想根据模式过滤掉文件,则需要使用 include/exclude/filter 选项.fileName 选项用于单个文件.
Yeah you need to use the include/exclude/filter option if you want to filter out files based on patterns. The fileName option is for a single file.
因此,在您的情况下,删除 fileName 选项并将其替换为 include=.*2280.xsl
.请注意,包含基于 Java 正则表达式,因此我们使用 点星 表示通配符.更多详细信息:https://camel.apache.org/components/latest/文件组件.html.ftp 组件继承了文件组件 99% 的选项,所以这就是我参考文件 wiki 页面的原因.
So in your case, remove fileName option and replace it with include=.*2280.xsl
. Mind that the include is based on Java regular expressions, so we use dot star to indicate wildcard. More details here: https://camel.apache.org/components/latest/file-component.html. The ftp component inherits 99% of the options of the file component, so that is why I refer to the file wiki page.
这篇关于HOW:Apache Camel、Regex 匹配文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!