我正在使用这个 Spring Boot Apache Camel 版本
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.4.0</version>
</dependency>
非常简单的场景,我试图将文件从一个文件夹复制到另一个文件夹。在理想情况下(没有给出超时),路由应该无限期地等待文件进入源文件夹。一旦文件来了,它应该选择它并再次循环并等待下一个。它适用于 Camel2.2,但不适用于最新版本。
代码:
from("timer:theTimer?period=10s")
.log("Timer Invoked . . . ")
.pollEnrich("file:data/input?delete=true&readLock=none")
.log("BODY = [ ${body} ] " )
.to("file:data/output");
任何骆驼专家的建议?
结果,我在输入目录中有 2 个文件。
使用camel2.2输出:
INFO 9248 --- [imer://theTimer] route1 : Timer Invoked . . .
INFO 9248 --- [imer://theTimer] route1 : BODY = [ FIle1 content ]
INFO 9248 --- [imer://theTimer] route1 : Timer Invoked . . .
INFO 9248 --- [imer://theTimer] route1 : BODY = [ File2 content ]
INFO 9248 --- [imer://theTimer] route1 : Timer Invoked . . .
<<Now it waiting for file and not doing anything>> ALL GOOD
使用camel3.4 springboot输出:[ERROR ONCE input DIR IS EMPTY]
INFO 13864 --- [imer://theTimer] route1 : Timer Invoked . . .
INFO 13864 --- [imer://theTimer] route1 : BODY = [ FIle1 content ]
INFO 13864 --- [imer://theTimer] route1 : Timer Invoked . . .
INFO 13864 --- [imer://theTimer] route1 : BODY = [ File2 content ]
INFO 13864 --- [imer://theTimer] route1 : Timer Invoked . . .
INFO 13864 --- [imer://theTimer] route1 : BODY = [ ]
2020-07-20 14:23:33.293 ERROR 13864 --- [imer://theTimer] o.a.c.p.e.DefaultErrorHandler : Failed delivery for (MessageId: ID-OUDQ5TZO1R-1595235193339-0-3 on ExchangeId: ID-OUDQ5TZO1R-1595235193339-0-3). Exhausted after delivery attempt: 1 caught: org.apache.camel.component.file.GenericFileOperationFailedException: Cannot write null body to file: data\output\ID-OUDQ5TZO1R-1595235193339-0-3