java - 如何在 Apache Camel 路由中再次读取跳过的文件?
问题描述
我正在使用 apache camelfile
组件从目录中读取所有文件。根据文件大小(如果列表中的文件大小与我当前正在阅读的文件大小不同),我想跳过该文件并在下一次迭代中再次选择它。那可能吗?我的代码剪断如下:
from("file://my/directroy/path/?recursive=true&noop=true&idempotent=false")
.aggregate(constant(true), new AggregationStrategy())
.completionSize(100).completionTimeout(100)
.split(body()).process(new Processor() {
public void process(Exchange exchange){
//Move this file only if the size is == new File("thisPath").length();
// othersize skip this for now and pick it up in next iteration
}
});
解决方案
https://camel.apache.org/components/3.4.x/file-component.html
根据文档,您可以使用:
filterFile (filter)
Filters the file based on Simple language. For example to filter on file size, you can use \${file:size} 5000
它看起来像:
from(file:{{replayDir}}/?filterFile=${file:size} 5000
有关简单语言支持,请参阅https://cwiki.apache.org/confluence/display/CAMEL/Simple
推荐阅读
- c# - 如何在 1 个按钮内运行 2 个命令
- xml - XSLT 1.0 - 在其他值之间子串一个值
- reactjs - React 函数式组件中的参数而不是 Props
- java - 将数组的字符串转换回数组
- visual-studio-code - VS Code 如何防止代码处于注释状态时代码自动展开?
- spring-jms - 如何确保 Spring JMS 并发消费消息?
- mysql - java.sql.SQLException:表被指定了两次,既作为“更新”的目标,又作为数据的单独源
- azure - BadRequest:由于引用无效,文档创建或更新失败
- python - numpy 如何存储图像数组?
- javascript - Sequelize mySQL 到 MS SQL 迁移