So, I am trying to learn Apache Camel, and the Hello World example they provide in the Camel in action book is the following:
public class FileCopierWithCamel {
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("file:data/inbox?noop=true").to("file:data/outbox");
}
});
context.start();
Thread.sleep(10000);
context.stop();
}}
This example tries to copy all files from a folder to another another one.
They say that it has less lines and praise how better it is when compared to a long Java version, which actually works better than the solution they propose using Camel.
I say this because this proposed solution suffers from a huge problem: it has a wait. Say that I want to copy 1000 files - or even better - that I do not exactly know the number of files I have in the folder (which is what happens in most cases). Using this solution I actually have to guess how long the operation is going to take. Not only is this a bad start already, it also makes no sense. I am a computer engineer, not a seer.
How can one modify this example as to only stop when it copies all the files?