Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Camel:从同一目录读取和写入_Java_File_Apache Camel_Integration - Fatal编程技术网

Java Camel:从同一目录读取和写入

Java Camel:从同一目录读取和写入,java,file,apache-camel,integration,Java,File,Apache Camel,Integration,我有一条骆驼路线: 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()) .

我有一条骆驼路线:

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分钟,然后使用轮询器检查条件。如果满足条件,则路线将继续。在另一种情况下,我希望将文件返回到同一目录(路径

此路由工作正常,甚至会显示日志消息“我稍后再试”,但之后,该文件将消失,并且不会返回到路径

发生了什么事?骆驼是不允许这样做的


谢谢

该文件很可能在目标目录中被覆盖,但完成后,它将被移动到
.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")
        .rollback() // rollback processing and keep file in original directory
.endChoice();
这是预期的行为,请参见:

在(post命令)布线完成后执行任何移动或删除操作


更好地回滚您的路由,默认情况下它会将文件保留在源目录中

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();