camerajbossfuseintegration-patterns

Camel ftp get file from ftp location on demand


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.


Solution

  • 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:password@ftp.server.com/${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:password@ftp.server.com/${header.CamelFolder}?fileName=${header.CamelDownloadFile}</simple>
      </pollEnrich>
      ...
    </route>