简体   繁体   English

Apache Camel:当我作为独立的Java项目运行时,轮询旧文件。 有没有办法只轮询新文件

[英]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.

相关问题 使用Apache Camel反复从只读文件系统中轮询文件(idempotent = false)? - Poll files from read-only filesystem repeatedly (idempotent=false) with Apache Camel? Apache Camel文件组件 - 如何仅扫描新文件? - Apache Camel File Component - how to scan for new files only? 我如何使用apache-camel在一次轮询中从aws s3目录中读取所有文件 - How do i can read all the files from aws s3 directory in a single poll using apache-camel 如何从多个文件中轮询最后修改的文件并发送到Apache骆驼中的目标端点? - How to poll last modified file out of multiple files and send to target endpoint in apache camel? 独立的Java程序 - Stand alone java program 单机 Java 编译器? - Stand Alone Java Compiler? 从独立应用程序轮询GMail收件箱以获取传入邮件的正确方法 - Right way to poll GMail inbox for incoming mail from stand-alone application 仅当 N 个文件出现在 Apache Camel 的多节点设置中时才开始处理 - Start processing only when N files show up in a multi node setup in Apache Camel 如何仅使用Apache Camel处理嵌套文件夹中的文件? - How do I only process files in nested folders using Apache Camel? 将独立的Java文件转换为项目包一部分的文件? - Converting a stand alone java file to a file that's part of a project package?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM