Search code examples
javaspringspring-integrationsftpspring-integration-sftp

Spring integration SFTP - Post Transfer processing


I have successfully set up Spring with SFTP integration, and am polling an SFTP server and pulling down files.

What I would like to know, is it possible for a task to be fired on each file once it's download has completed? I don't want to go down the road of filesystem watches - is there something built into Spring SFTP for this?

Having looked at the documentation, it looks like it can be achieved with Channels.

This is what my receiver channel currently looks like:

<int:channel id="receiveChannel">
    <int:queue />
</int:channel>

I'm not sure what I need to do to fire a customer interceptor or similar.

Edit: from the Spring docs it says this:

It is also important to understand that SFTP Inbound Channel Adapter is a Polling Consumer and therefore you must configure a poller (either a global default or a local sub-element). Once the file has been transferred to a local directory, a Message with java.io.File as its payload type will be generated and sent to the channel identified by the channel attribute.

I'm not sure how to implement this - and can't find any examples.


Solution

  • For the benefit of others who come across this, the issue is that the messages are put on the received channel only when ALL files have been transferred. They are not handled one at a time (as I had expected). In my case I have thousands of large files on a remote SFTP server, and only after all of them downloaded were the messages sent to the receiver channel.

    I'm not sure if this is by design.