[英]Apache Camel : Polling the old files when I run as stand alone java project. Is there a way to poll only the new files
I have a requirement to transfer the files from my local specific folder location to other location. 我需要将文件从本地特定文件夹位置传输到其他位置。 I am using Apache Camel as a stand alone project and here is my code 我正在使用Apache Camel作为独立项目,这是我的代码
from(file:<location>?noop=true).to(file:<location>)
Whenever I run as a Java project, It keeps on polling the old files as well which is moved on previous run. 每当我以Java项目的身份运行时,它还会继续轮询旧文件,并在上一次运行时将其移动。 Is there a way to poll only the new files and also I am unable to log the file transfers 有没有办法只轮询新文件,而且我无法记录文件传输
Example: On First run : source directory has 示例:首次运行时:源目录具有
Folder1/image1
from(file:Folder1?noop=true).to(file:Folder2)
Will move the image1 to Folder2 location and image1 will remain in the Folder1.
将image1移到Folder2位置,而image1将保留在Folder1中。
Now I am going to run the java file again and I added one more file image2 to the source directory
现在,我将再次运行Java文件,并将另一个文件image2添加到源目录中
FFolder1/image1 & image2
Now In this case I want only the image2 file to be processed, but the code process the image1 as well. 现在,在这种情况下,我只希望处理image2文件,但是代码也要处理image1。
since noop=true the file still remains in the source folder after the java process with camel routes is started. 由于noop = true,因此在启动带有骆驼路线的Java进程后,该文件仍保留在源文件夹中。 When you restart the java program it does not remember anything and hence polls all the files in source folder again. 重新启动Java程序时,它什么也记不清,因此会再次轮询源文件夹中的所有文件。 noop=true helps if the route is running continuously and not restarted. 如果路由连续运行且未重新启动,noop = true会有所帮助。
You can avoid this by removing noop so the camel route moves the processed files from the source folder to a .camel folder or any folder you specify. 您可以通过删除noop来避免这种情况,因为骆驼路由会将已处理的文件从源文件夹移动到.camel文件夹或您指定的任何文件夹。
The solution depends on how you use it. 解决方案取决于您的使用方式。 If there is a strict requirement not to move files from the source folder then you need to remember it on the consumer side who consumes the destination folder, so you do not process the same files again or the route should not be restarted. 如果严格要求不要从源文件夹移动文件,那么您需要在使用目标文件夹的使用者方记住该文件,因此您不必再次处理相同的文件,否则不应重新启动路由。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.