使用apache camel复制相关文件

时间:2012-06-06 18:58:17

标签: apache-camel

首先:我是一个骆驼新手: - )

我想要查看xml文件的目录,然后我想将该xml文件移动到另一个目录并将具有相同文件名(但是其他扩展名)的pdf文件移动到同一目录,然后执行一些java内容。

移动该pdf文件的最佳方法是什么?

这是我目前的路线:

from("file://C:/temp/camel/in?delete=true").filter(new Predicate() {

        @Override
    public boolean matches(final Exchange exchange) {
                String filename = (String) exchange.getIn().getHeader("CamelFileRelativePath");
        return "xml".equals(FilenameUtils.getExtension(filename));
    }
})
.to("file://C:/temp/camel/out").bean(ServiceBean.class, "callWebservice")

谢谢!

1 个答案:

答案 0 :(得分:0)

你可以不使用过滤器而是使用正则表达式来过滤2个扩展名,.xml和.pdf

from("file://C:/temp/camel/in?delete=true&?include=.*.xml|.*.zip")                      
    .to("file://C:/temp/camel/out").bean(ServiceBean.class, "callWebservice");

如果您使用过滤器,它将删除您不感兴趣的文件,这可能不是您想要的,此解决方案只会将它们保留在该目录中