2

我目前有以下骆驼路线:

//Only continue to next route if success
from("file:///tmp/camel/input")
    .routeId("Test Route")
    .to("file:///tmp/camel/test")
    .onCompletion().onCompleteOnly()
        .log("Success for file: ${header.CamelFileName}")
        .setHeader("recipientList", constant("file:///tmp/camel/output, file:///tmp/camel/output2"))
        .recipientList(header("recipientList"))
    .end();

仅当先前的路由成功时才需要向收件人发送文件。

但是,在运行该路线时,我得出的结论是 onCompletion() 块中的 .to 也从输入文件夹中读取,但文件已经消失,因此无法将它们拾取并将它们写入收件人。(我不能在 from 处设置 noop=true,因为我确实希望文件在发送给收件人之后消失......)

那么我们如何将文件路由给收件人,以之前成功的路由为先决条件呢?

4

1 回答 1

0

这将起作用

from("file:///tmp/camel/input")
            .routeId("Test Route")
            .to("file:///tmp/camel/test?noop=true")
            .onCompletion().onCompleteOnly()
            .log("Success for file: ${header.CamelFileName}")
            .end();

from("file:///tmp/camel/test?noop=true")
           .to("file:///tmp/camel/output")
           .to("file:///tmp/camel/output2");

我觉得这里是多余的,因为如果文件传输失败 OnCompletion,第二条路由不会触发。/camel/test

另一点是您可以使用move=.done选项来确保在传输完整文件之前不会启动第二条路线

from("file:///tmp/camel/test?noop=true&move=.done")
            .to("file:///tmp/camel/output")
            .to("file:///tmp/camel/output2")
于 2018-02-28T14:45:12.663 回答