我正在读取和处理来自 2 个不同文件位置的 2 个文件并比较内容。 如果第二个文件不可用,则其余过程将使用第一个文件执行。如果第二个文件可用,比较过程应该发生。为此,我正在使用 camel pollEnrich,但这里的问题是,camel 仅在第一次选择第二个文件。如果不重新启动 Camel 路线,第二个文件即使存在也不会被拾取。 重新启动 Camel 路线后,它工作正常,但之后它没有选择第二个文件。
我正在将文件处理后移动到不同的位置。
下面是我的代码,
from("sftp:" + firstFileLocation + "?privateKeyFile=" + ppkFileLocation + "&username=" + sftpUsername
+ "&readLock=changed&idempotent=true&move=" + firstFileArchiveLocation)
.pollEnrich("sftp:" + secondFileLocation + "?privateKeyFile=" + ppkFileLocation + "&username=" + sftpUsername
+ "&readLock=changed&idempotent=true&fileExist=Ignore&move="+ secondFileLocationArchive ,10000,new FileAggregationStrategy())
.routeId("READ_INPUT_FILE_ROUTE")
需要帮助。
最佳答案
您在 sftp 消费者中设置 idempotent=true
,这意味着 camel 不会处理相同的文件名两次。由于您正在移动文件,因此设置 idempotent=false
是有意义的。
引自 Camel documentation
Option to use the Idempotent Consumer EIP pattern to let Camel skip already processed files. Will by default use a memory based LRUCache that holds 1000 entries. If noop=true then idempotent will be enabled as well to avoid consuming the same files over and over again.
关于java - Camel pollEnrich 第二次没有工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73274232/