0

I have a new requirement in Apache camel where I need to read a file from an FTP location which contains the file name another file in the same FTP location. So I need to read the first file get the file name and read the second file name. How do we achieve in Apache camel?

Raj
  • 115
  • 8
  • What have you tried to acheive this? – Souciance Eqdam Rashti Jun 19 '17 at 06:41
  • I tried below option but how to get filename2 from file1 is the question from("ftp://servername?"+"password=password"+"&antInclude=filename") .process(new Processor() { public void process(Exchange exchange) throws Exception { exchange.getIn().setBody(exchange.getIn().getBody(),String.class); } }) .from(ftp://servername?"+"password=password"+"&antInclude=filename_2") – Raj Jun 19 '17 at 13:31
  • I think you need to review the basics again. Route 1 should fetch the file, extract the body and set it in a exchange property or header and then call route 2 which looks in the location where you stored the body of the file and does the ftp fetch. – Souciance Eqdam Rashti Jun 19 '17 at 13:46

1 Answers1

1

You can write a simple FTP route that consumes the first file (that contains the target file name). Once this file is read, you can forward the content to a route builder, where you build the other FTP route that will consume the target file.

You can make use of the FTP component include option to specify the pattern of the files names to consume.

Ahmad Y. Saleh
  • 3,309
  • 7
  • 32
  • 43
  • I tried below option but how to get the file name from the previous file. { from("ftp://servername?"+"password=password"+"&antInclude=filename") .process(new Processor() { public void process(Exchange exchange) throws Exception { exchange.getIn().setBody(exchange.getIn().getBody(),String.class); } }) .from(ftp://servername?"+"password=password"+"&antInclude=filename_2")} – Raj Jun 19 '17 at 13:28