I\'m trying to use Apache Camel to download and route files from an FTP server. However, files are only added to the FTP server once in a long while so having the program r
Completing Claus answer, this code run in a only once fashioned way Main:
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.main.Main;
public class MyMainRouter extends RouteBuilder {
static Main main;
@Override
public void configure() throws Exception {
from("timer:foo?delay=5s")
.log("Hello camel, main world after 5 seconds!")
.process(processor -> main.completed());
}
public static void main(String[] args) throws Exception {
main = new Main();
main.addRouteBuilder(new MyMainRouter());
main.run();
}
}
After 5 seconds, the code will run only once, because we will call a processor that will call completed() method, wich internally have CountDownLatch stopping a route pattern from another thread.