I want to run a simple Apache Camel example that copies files from one directory to another:
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure () throws Exception {
from("file://c:/fromdir/").to("file://c:/todir/");
}
});
context.start();
If I run this example using Apache Camel 2.0.0 the program exits immediately after context.start();
and does nothing. If I add Thread.sleep(30000);
after the starting of the CamelContext
, the background threads do their work and files get copied from the source to the destination directory for 30 seconds.
However, if I run the same code using Apache Camel 1.6.2 the start()
method blocks automatically and I don t need to put the main thread to sleep in order to get files copied. I haven t found a hint that this behavior changed from Camel 1.x to 2.x. Is this really the intended behavior? Is it possible to let the start() method block the execution in Camel 2.0.0?
Thanks