首先:我是一个骆驼新手:-)
我想将文件从输入目录传输到输出目录并做一些java的东西.如果出现问题,我想将文件移动到错误目录并回滚以移动到输出目录.
这是我在java dsl中的路线:
onException(Exception.class).handled(true).to("file://C:/temp/camel/error");
from("file://C:/temp/camel/in?delete=true").to("file://C:/temp/camel/out").bean(ServiceBean.class, "callWebservice");
如果在ServiceBean中引发错误,则该文件将复制到错误文件夹,但它也会保留在out目录中.
回滚的最佳方法是什么?
谢谢
有一个moveFailed选项.只需使用它,那么你就不需要onException等 http://camel.apache.org/file2
from("file://C:/temp/camel/in?delete=true&moveFailed=C:/temp/camel/error")
  .to("file://C:/temp/camel/out")
  .bean(ServiceBean.class, "callWebservice");
而不是存储在路线中,然后只需使用移动选项,它就变成了
from("file://C:/temp/camel/in?move=/temp/camel/out&moveFailed=/temp/camel/error")
  .bean(ServiceBean.class, "callWebservice");