Hi, I'm trying to do something fairly simple: copy a file via sftp to localhost. I build a route with sftp and file components. This is event driven, so I don't want to have a consumer constantly polling.
I'm trying to follow the sample described at "Consuming a remote FTP server triggered by a route" http://activemq.apache.org/camel/ftp.html where it shows a message comes in from a seda queue that has the path/host to the file. I'm trying to do exactly the same thing without the seda queue. See the method below which will be executed when I receive an event that a file is ready to be downloaded. context is CamelContext injected via spring so it should already be started. @Override public File download(String host, String localDirectory, String remotePath) { // the sftp url final String url = getUrl(host, remotePath); // path to local file final String localFile = getLocalFilePath(localDirectory, remotePath); try { context.addRoutes(new RouteBuilder() { public void configure() { from(url).process(new Processor() { @Override public void process(Exchange exchange) throws Exception { Endpoint ftp = context.getEndpoint(url); PollingConsumer consumer = ftp.createPollingConsumer(); consumer.start(); Exchange result = consumer.receive(); exchange.getIn().setBody(result.getIn().getBody()); consumer.stop(); } }).to("file://"+localFile); } }); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } When I try this, the log messages indicate: remote endpoint is created -> 12:02:28,538 DEBUG [main] impl.DefaultCamelContext (DefaultCamelContext.java:333) - sftp://t...@198.180.208.188/home/toor/newfile.txt?password=password&binary=true&directory=false&consumer.delay=5000&consumer.deleteFile=true converted to endpoint: Endpoint[sftp://t...@198.180.208.188/home/toor/newfile.txt] by component: RemoteFileComponent local file endpoint is created -> 12:02:28,647 DEBUG [main] impl.DefaultComponentResolver (DefaultComponentResolver.java:67) - Found component: file via type: org.apache.camel.component.file.FileComponent via META-INF/services/org/apache/camel/component/file 12:02:28,663 DEBUG [main] impl.DefaultComponent (DefaultComponent.java:79) - Creating endpoint uri=[file://C:\SVN\.\target\newfile.txt], path=[C:\SVN\.\target\newfile.txt], parameters=[{}] 12:02:28,663 DEBUG [main] impl.DefaultCamelContext (DefaultCamelContext.java:333) - file://C:\SVN\.\target\newfile.txt converted to endpoint: Endpoint[file://C:\SVN\.\target\newfile.txt] by component: org.apache.camel.component.file.filecompon...@9b87f6 consumer is started -> 12:02:28,803 INFO [main] remote.SftpConsumer (SftpConsumer.java:51) - Starting 12:02:28,819 DEBUG [main] impl.DefaultCamelContext (DefaultCamelContext.java:401) - Adding routes from: Routes: [Route[[From[sftp://t...@198.180.208.188/home/toor/newfile.txt]] -> [Interceptor[Delegate(Pipeline[DeadLetterChannel[Delegate(sftpfiledownloader$...@8b6c39), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error]], DeadLetterChannel[Delegate(sendTo(Endpoint[file://C:\SVN\.\target\newfile.txt])), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error]]])]]]] routes: [] ...but nothing happens after that? the file isn't copied, no exception is thrown, etc. I call it from a JUnit test, and the test just exits. I think I must be missing something simple? Regards, Davis