apache - 防止 apache camel 将不合格的文件移动到 .camel
问题描述
我正在创建一个简单的文件传输实用程序,根据用户输入搜索文件夹中的文件并将匹配的文件传输到目的地。问题是骆驼正在移动所有与 .camel 文件夹不匹配的文件,我不希望这种情况发生在下面是我的片段。
from("file:C:\\input?noop=true;").
filter(header(Exchange.FILE_NAME)
.contains("xyz")).split(body().tokenize("\n")).
streaming().bean(LineParser.class, "process").
to("file:"+ Constants.getMapping().get(argumentName)+"?
fileExist=Append");
提前致谢 !!
解决方案
查看文件组件使用者选项:http ://camel.apache.org/file2.html 。您应该能够在 from uri 中使用“filter”或“filterFile”选项。正如克劳斯上面提到的,这些将在端点过滤。如果您能够使用 Simple 语言,则 filterFile 会更简洁:
from("file:C:\\input?filterFile=...
否则,您可以创建一个过滤器 bean 来处理过滤并使用过滤器选项来引用该 bean。请注意,不再需要 filter().contains() :
from("file:C:\\input?filter=#someFileFilter")
.split(body().tokenize("\n"))
.streaming()
.bean(LineParser.class, "process")
.to("file:"+ Constants.getMapping().get(argumentName)+"?fileExist=Append");
public class SomeFileFilter<T> implements GenericFileFilter<T> {
@Override
public boolean accept(GenericFile<T> file) {
// return true if file should be included, false if excluded
}
}
推荐阅读
- express - 会话 Cookie 未保存在浏览器上
- nagios - Nagios Core 错误无法获取进程状态
- algorithm - 寻找长度为 3 的递增序列的最低成本的算法
- javascript - 无法设置未定义的属性 - 模态库 - 可能的范围问题?
- ubuntu-server - 在 ubuntu 中创建新的挂载点
- javascript - 在电子中获取 webview 中的单击元素
- python - 如何将所有变量转换为浮点数
- hashcode - 3 int 的哈希码没有冲突
- php - PHP - array_diff 给出数组到字符串的转换错误
- asp.net-core - Asp Net Boilerplate - 多租户、零模块和附加模块