The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

tom1000 (2) [Avatar] Offline
#1
Hello,

I modified the Chapter 2- ftp-jms example (FtpToJMSWithProcessorExample) to use a valid sftp url with a user/pwd and it works as I expected (the file at the source location is transferred to the target location), except that processing does not finish after the 'to' function completes as I thought would be the case. The route is apparently reprocessed until context.stop() is called (the file is continuously transferred to the destination). If this is to be expected, how can I have the route processing terminate once the file{s} have been transferred ?

Thanks,
Tom
janstey (72) [Avatar] Offline
#2
Re: Chapter 2- ftp-jms : how can you get the route to stop iterating
Try setting idempotent=true on the URI; this will make the FTP consumer only process the same file once. It is continuously trying to consume the same file because by default Camel will not delete the remote FTP file so it stays on the server. You can change this behavior by using the delete=true option to delete the remote files, or move=.done to move the files into a hidden ".done" sub directory.

Cheers,
Jon
tom1000 (2) [Avatar] Offline
#3
Re: Chapter 2- ftp-jms : how can you get the route to stop iterating
Thanks Jon. I probably should have been more explicit. I know there are ways to stop the same file from being resent, but what I'm looking for are ways to stop the route from being reprocessed so that the route is only executed once. I just started looking at Camel, and thought that a route would by default only get run once when a context is started, apparently, that is not the case. Much further in the book, I see an example of stopping a route from being reprocessed by appending the .routeId("route-id") method call to the 'from' and then stopping the route by adding a Processor after the '.to' call (via .process()) to perform the following:
exchange.getContext().getInflightRepository().remove(exchange);
exchange.getContext().stopRoute("route-id");
This works, but I'm interested to know if there's a simpler way of telling of the framework to stop a route from iterating. Maybe this is covered elsewhere in the book.

Thanks,
Tom
davsclaus (413) [Avatar] Offline
#4
Re: Chapter 2- ftp-jms : how can you get the route to stop iterating
Chapter 13 covers more about starting and stopping Camel.