Hi You can stop Camel itself from the route when the last file has been processed. See this FAQ http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html
The file component has a property on the exchange, that tells you if its the last file. You can use this code in that FAQ above to call the stop method when its the last message: boolean isLast = exchange.getProperty(Exchange.BATCH_COMPLETE, Boolean.class, false); You can also configure the route to shutdown all pending messages http://camel.apache.org/configuring-route-startup-ordering-and-autostartup.html And then have a large timeout value (which is 300 sec by default). Which mean that if you call stop on CamelContext, and there is in-flight messages, it will complete those messages first, and only when the timeout is hit, it will force a shutdown. On Tue, Nov 15, 2011 at 4:32 PM, marcelk <[email protected]> wrote: > Hello, > > I've got a very simple question. > I want to copy files from the outbox to an ftp. > So I have the route and it works fine. > But when do I need to close the camelContext? > When I close it too early the ftp might not be finished. > > What is the best approach? I dont want to do thread.sleep. > > from("file://outbox") > .errorHandler(deadLetterChannel("direct:error")) > .log("Going to FTP!").to("ftp://whatever.com").log("FTP Done!"); > > from("direct:error").log("Error occured during FTP").to( > "file://errorbox"); > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Do-i-need-to-wait-for-endpoint-ftp-to-finish-tp4994642p4994642.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Claus Ibsen ----------------- FuseSource Email: [email protected] Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/
