如何使用 apache camel 将文件从一个文件夹顺序传输到另一个文件夹?

How to transfer files sequentially from one folder to another using apache camel?

我在一个文件夹中有一些文件:

abc.zip(可选)

def.zip(可选)

ghi.zip(可选)

我想按顺序发送到目标文件夹。 它们将从目标文件夹发送到第 3 方系统。 所以,假设 abc.zip 被转移到目标文件夹,除非它被第三方系统选择 def.zip 不应该被转移到目标文件夹。

所以,目标文件夹就像监视文件夹,我想检查以前的文件是否存在,或者 not.If 不然后只发送下一个文件。

有什么方法可以使用 apache camel 来实现吗?

为了实现这一点,听起来您需要实现 org.apache.camel.component.file.GenericFileProcessStrategy class 并将其设置为文件组件上的 processStrategy。这样您就可以检查目标位置是否有任何具有较早名称的文件。

来自文档(强调已添加):

A pluggable org.apache.camel.component.file.GenericFileProcessStrategy allowing you to implement your own readLock option or similar. Can also be used when special conditions must be met before a file can be consumed, such as a special ready file exists. If this option is set then the readLock option does not apply.