以成功路线为先决条件的路线(骆驼)
Route with successful route as prerequisite (Camel)
我目前有以下骆驼路线:
//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也从输入文件夹中读取,但是文件已经消失了,所以它不能选择并将它们写给收件人。 (我不能在发件人处设置 noop=true,因为我确实希望文件在发送给收件人后消失...)
那么我们如何将文件路由到收件人,前提条件是之前的路由成功?
这会起作用
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")
我目前有以下骆驼路线:
//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也从输入文件夹中读取,但是文件已经消失了,所以它不能选择并将它们写给收件人。 (我不能在发件人处设置 noop=true,因为我确实希望文件在发送给收件人后消失...)
那么我们如何将文件路由到收件人,前提条件是之前的路由成功?
这会起作用
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")