Apache camel Sql超时。骆驼上下文Bean对多个文件失败

Apache camel Sql超时。骆驼上下文Bean对多个文件失败,apache-camel,Apache Camel,当文件被放入文件夹时,我运行自动路由 <route id ="automatic-route"> <from uri="file:C:/pathToFolder?noop=true"/> <to uri="bean:automaticBean"/> <to uri="activemq:STARTFLOW.Q"/> </route> 我使用Bean AutomaticBean.java

当文件被放入文件夹时,我运行自动路由

<route id ="automatic-route">
        <from uri="file:C:/pathToFolder?noop=true"/>
        <to uri="bean:automaticBean"/>
        <to uri="activemq:STARTFLOW.Q"/>
</route>

我使用Bean AutomaticBean.java中的java方法将文件移动到名为“done”的子文件夹中

然后我启动另一个路径来处理文件

<route id ="process-route">
        <from uri="direct:process"/>
        <to uri="bean:processBean"/>
</route>

当我移动文件夹中的多个文件时,它们会正确地移动到子文件夹中(通过我的Bean。我使用java方法移动它们)。但是第二个bean(文件处理和SQL查询)有timeoutException,因为文件是同时移动和处理的

例如,当我移动5个文件时,其中3个文件已正确处理,但最后一个文件具有timeoutException。是否可以为每个文件逐个运行第二个路由(计划它们或类似的内容)?只有在正确处理前一个文件后,才能启动文件的第二个路由

我试过用noop=false;move=done,我有无限循环问题,无法处理文件,因为它们已移动。这就是为什么我使用noop=true。此外,我的问题是关于第二条路线(文件都正确移动了)


谢谢。

一种解决方案是轮询
/done
文件夹中的新文件(这些文件已由您的
automaticBean
处理和移动)。在这种情况下,必须使用
readLock
doneFileName
检查文件是否未被其他进程锁定

<route id ="process-route">
    <from uri="file:C:/pathToFolder/done?readLock=changed"/>
    <to uri="bean:processBean"/>
</route>

实际上,将maxMessagePerPoll设置为1时添加一个延迟就成功了

<route id ="process-route">
    <from uri="file:C:/pathToFolder/noop=true&amp;delay=10000&amp;maxMessagesPerPoll=1"/>
    <to uri="bean:processBean"/>
</route>