我正在努力实现:
- 读取 s3 目录中的所有文件。
- 将所有文件复制到 s3 上的备份目录。
- 将所有文件内容聚合到一个文件并将其复制到 s3 上的另一个目录。
但我坚持在第一点上在一次轮询中读取所有文件。
我的路由器:
aws-s3://${camel.bucket.name}?amazonS3Client=#s3Client&prefix=some_path_on_s3&deleteAfterRead=true&delay=100s
for example if, some_path_on_s3 -> has 2 files say first.txt and
second.txt
according to camel documentation, it has to read both the files in a
single poll, but is reading 1 file per poll.
I also tried with parameter, maxMessagesPerPoll=2 but no luck. It
still reads one file per poll.
有没有办法在一次轮询中从 s3 目录中获取所有文件?
最佳答案
事实上,它一次向路由发送一个文件,但每次轮询都会确认整个批处理。
maxMessagesPerPoll 仅对每批读取的文件数量设置限制。我认为您正在寻找的信息位于每个交易所的驼峰批标题上:
CamelBatchComplete:一个 boolean 值,指示批处理中的最后一个交换。仅适用于最后一个条目。
CamelBatchIndex:批处理的当前索引。从0开始。
CamelBatchSize:此批处理中轮询的 Exchange 总数。
利用此信息,您可以多播消息,然后实现聚合器以在一条路由上加入文件(一旦 CamelBatchComplete=true),并在另一条路由上备份文件。
在此处查找更多信息:
关于java - 如何使用 apache-camel 在一次轮询中读取 aws s3 目录中的所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56954730/