Search code examples
javaspringspring-integrationsftpspring-integration-sftp

Sftp from windows server spring integration


I have a requirement to sftp different files onto a server.

The files that are in scope for delivery resides in a Windows server.

I thought of using Spring Integration adapters for this purpose as not only do I have to deliver files but also have additional requirement of writing metadata information to database for each file delivery.

Do you have any idea how I can sftp multiple files that are on a windows file share to other servers using spring integration?


Solution

  • The standard FileReadingMessageSource does exactly request functionality: https://docs.spring.io/spring-integration/docs/4.3.12.RELEASE/reference/html/files.html#file-reading.

    There you can use that shared Windows dir to pull files and then you will send messages to the SftpMessageHandler: https://docs.spring.io/spring-integration/docs/4.3.12.RELEASE/reference/html/sftp.html#sftp-outbound.

    But since we deal with message channels in Spring Integration that pretty easy to send messages somewhere else, e.g. to JDBC.