gpt4 book ai didi

java - Camel : Read and Write from the same directory

转载 作者:行者123 更新时间:2023-11-29 04:08:14 26 4
gpt4 key购买 nike

我有这条 Camel 路线:

final String URI_FILE = "file:{{PATH}}";
final String POOLER = "&scheduler=quartz2&scheduler.cron=0+0/10+*+*+*+?";

from(URI_FILE + POOLER)
.pollEnrich().simple("{{URL_CHECKER}}",String.class).aggregationStrategy(new myEstratey())
.choice()
.when(exchangeProperty("CONTINUE").isEqualTo(true))
.log("Condition was met")
.to(URI_DIRECT) //To another route
.endChoice()
.otherwise()
.log("I'll try again later")
.to(URI_FILE)
.endChoice();

我想每10 分钟PATH 读取一个文件,然后使用pollEnrich 检查条件。如果满足条件,路由继续。在另一种情况下,我想将文件返回到同一目录 (PATH)。

这条路线工作正常,甚至显示日志消息“我稍后再试”,但在那之后,文件就消失了,没有返回到 PATH

发生了什么事?在 Camel 中不允许这样做吗?

谢谢!!

最佳答案

该文件很可能在目标目录中被覆盖,但在完成后,它被移动到 .camel 目录。

这是预期的行为,请参阅 File component docs :

Any move or delete operations is executed after (post command) the routing has completed


最好回滚你的路由,默认情况下它会将文件保存在源目录中。

final String URI_FILE = "file:{{PATH}}";
final String POOLER = "&scheduler=quartz2&scheduler.cron=0+0/10+*+*+*+?";

from(URI_FILE + POOLER)
.pollEnrich().simple("{{URL_CHECKER}}",String.class).aggregationStrategy(new myEstratey())
.choice()
.when(exchangeProperty("CONTINUE").isEqualTo(true))
.log("Condition was met")
.to(URI_DIRECT) //To another route
.endChoice()
.otherwise()
.log("I'll try again later")
.rollback() // rollback processing and keep file in original directory
.endChoice();

关于java - Camel : Read and Write from the same directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56858514/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com