我有以下 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/