java - Apache Camel 文件组件 : Specifying 1 file in regex

标签 java regex file apache-camel

我有以下 Camel 路线(Spring XML);

<route id="myroute">
    <from uri="file:///home/myuser/someDir?include=toprocess_*.txt" />

    <to uri="bean:fileProcessor?method=process" />
</route>

在我机器的文件系统上:

/home/user/someDir/
    toprocess_1.txt
    toprocess_2.txt
    toprocess_3.txt
    ...
    toprocess_13904.txt

如何更改 include 选项(或一般的 uri)以便只有 first 文件(无论其名称如何)匹配正则表达式被添加到路由,然后路由到 fileProcessor bean?

请注意,在我的例子中,第一个文件很可能是toprocess_1.txt。但是我可以有一个像这样的文件系统:

/home/user/someDir/
    toprocess_red.txt
    toprocess_blue.txt
    toprocess_green.txt
    ...
    toprocess_black.txt

所以这不仅仅是制作 URI 这么简单:

<from uri="file:///home/myuser/someDir?include=toprocess_1.txt" />

我期待这样的事情:

<from uri="file:///home/myuser/someDir?include=toprocess_*.txt&maxFiles=1" />

但是在Camel docs ,我看不到这样的选项或类似的选项。

最佳答案

我相信你可以这样做:

<route id="myroute">
    <from uri="timer:foo?repeatCount=1" />
    <pollEnrich uri="file:///home/myuser/someDir?include=toprocess_*.txt" />
    <to uri="bean:fileProcessor?method=process" />
</route>

关于java - Apache Camel 文件组件 : Specifying 1 file in regex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20686344/

相关文章:

javascript - 限制reactjs中的字符数

c# - 从 C# 中的完整文件路径解析目录名称

c - 访问功能是否检查文件的存在?

java - 绘制图表

java - 如何对Firebase数据库中的数据进行升序排序

regex - 正则表达式从开始到换行都获取每个字符串?

C++ 应用程序 : opening file fails because of language?

java - 每年定时器不起作用

java - 将 Spoon 模型转换为其他模型

python - 将带括号的内容过滤到 Python 列表中