camel文件组件正在连续读取同一文件而不检测其他文件。
我有一条骆驼路线,
<camelContext trace="false" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="file:C:/Books/input_dir?noop=true"/>
<dynamicRouter>
<method ref="fileRouter" method="routeFiles"></method>
</dynamicRouter>
</route>
</camelContext>
<bean id="fileRouter" class="org.test.demo.DynamicRouter"/>
和路由器为,
public class DynamicRouter {
public String routeFiles(Exchange exchange){
final String fileName = (String) exchange.getIn().getHeader(Exchange.FILE_NAME_ONLY);
System.out.println("FILENAME: "+fileName);
if(fileName.contains("survival")){
return "file:C:/Books/output_dir";
}else {
return "file:C:/Books/target_dir";
}
}
}
每当文件说 beahomelist 被删除到C:/Books/input_dir
文件夹时,它会读取第一个文件,并且永远不会停止在下面的日志中
FILENAME:beahomelist FILENAME:beahomelist FILENAME:beahomelist FILENAME:beahomelist FILENAME:beahomelist FILENAME:beahomelist FILENAME:beahomelist FILENAME:beahomelist ....
并且doest没有检测到放在同一文件夹中的任何其他文件。即使noop = true,它也会发生。请提供一些建议。我使用的是骆驼版:2.13.0
答案 0 :(得分:1)
阅读有关动态路由器eip的文档,请注意!顶部的框
虽然看起来您应该使用“动态到”而不是动态路由器,但请参阅此常见问题解答
所以只需使用
<recipientList>
<method ref="fileRouter" method="routeFiles"></method>
</recipientList>