Camel ftp get file from ftp location on demand

1k Views Asked by At

Hi I have a scenario where I get notified through a soap service call to pick file from an remote ftp location.The ftp server details would be same but the folder name and file will be sent dynamically, How can i implement it using apache camel.? Any suggestions or thoughts might be helpful.

1

There are 1 best solutions below

4
Themis Pyrgiotis On BEST ANSWER

I think you should use headers for that. So, you will load your dynamic information into headers and use them in the ftp component with toD.

So you can have something like the following

<toD uri="sftp:username:[email protected]/${header.CamelFolder}?fileName=${header.CamelDownloadFile}"/>

But since you want to get from an FTP in the middle of the route you can try Content Enricher EIP

<route>
  <from uri="..."/>
  <!-- set your dynamic values as headers -->
  <setHeader headerName="CamelFolder">
     <simple>...</simple>
  </setHeader>
  <setHeader headerName="CamelDownloadFile">
     <simple>...</simple>
  </setHeader>

  <pollEnrich>
    <simple>sftp:username:[email protected]/${header.CamelFolder}?fileName=${header.CamelDownloadFile}</simple>
  </pollEnrich>
  ...
</route>