简体   繁体   中英

camel stop when there are no files in the folder

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");   
      }
   };
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM