camel stop when there are no files in the folder

五迷三道 提交于 2019-12-13 00:16:34

问题


I'm new to camel. I'm trying to create a small application that allows me to move a file from one location to another. I am forced to use camel for various reasons. I can execute the move but I can not make camel stop when there are no more files within the folder. I tried in several ways but without success.

Here is the code I used:

try {
   Main main = new Main();
   main.addRouteBuilder(createRouteBuilder());
   main.run();
} catch (Exception e1) {
   e1.printStackTrace();
}

protected RouteBuilder createRouteBuilder() throws Exception {
   return new RouteBuilder() {
      public void configure() throws Exception {
          from("file:./xxx").to("file:C:\\tomcat-6.0.37\\apache-tomcat-6.0.37\\yyy");   
      }
   };
}

回答1:


Configure your file endpoint to send an empty message when there are no more files to process. Then in your route you can detect the empty message and shut down the route following this http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html



来源:https://stackoverflow.com/questions/20638680/camel-stop-when-there-are-no-files-in-the-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!