下面列出的代码可以正常工作,但是它的功能是查看XML文件,如果该字段是'us',则将其移动到另一个目录。我想知道有关使用.choice()函数的什么:
1)如何指定要路由的特定文件?(将文件名添加到路径末尾不起作用)
2)如何指定要路由的文件类型?(例如:将所有.txt文件路由到“等等”)
3)除了使用.choice以外,还有其他选择可以帮助我做到这一点吗?
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder()
{
public void configure() throws Exception
{
from("file:C:\\camels\\inner?delete=true")
.choice()
.when(xpath("/author/country = 'us'"))
.to("file:C:\\testing");
}
});
context.start();
Thread.sleep(10000);
context.stop();
Run Code Online (Sandbox Code Playgroud)