骆驼:从同一目录读取和写入
Camel: Read and Write from the same directory
我有这条骆驼路线:
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。如果满足条件,路由继续。在另一种情况下,我想 return 文件到同一目录 (PATH).
此路由工作正常,甚至显示日志消息 "I'll try again later",但在那之后,文件就消失了,并且没有 returned 到 PATH
这是怎么回事?在骆驼中不允许这样做吗?
谢谢!!
该文件很可能在目标目录中被覆盖,但在完成后,它被移动到 .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();
我有这条骆驼路线:
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。如果满足条件,路由继续。在另一种情况下,我想 return 文件到同一目录 (PATH).
此路由工作正常,甚至显示日志消息 "I'll try again later",但在那之后,文件就消失了,并且没有 returned 到 PATH
这是怎么回事?在骆驼中不允许这样做吗?
谢谢!!
该文件很可能在目标目录中被覆盖,但在完成后,它被移动到 .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();