0

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?

M06H
  • 1,675
  • 3
  • 36
  • 76

1 Answers1

1

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.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • Thanks Artem. Could you show me how to wire in JDBC metadata writing class for each file transfer that is picked up by `FileReadingMessageSource`, processed by `SftpMessageHandler`? – M06H Sep 24 '17 at 16:58
  • You can use PublishSubscribeChannel for that task. And have SFTP and JDBC channel Adapters as subscribers to it. Of course, you can find that info in the mentioned document. Also you can study more Spring Integration in the Samples repo: https://github.com/spring-projects/spring-integration-samples – Artem Bilan Sep 24 '17 at 18:44
  • Hi - with FileReadingMessageSource, say my application is hosted on Host A and has access to network path Host B, can it read files from Host B ? Or files have to be in Host A – M06H Sep 26 '17 at 06:55
  • Yes, it can read from the network or mounted device as well. In other words: as far as you can deal with `File` object as long as the `FileReadingMessageSource` is useful for you. – Artem Bilan Sep 26 '17 at 10:37