1
votes

I am using Spring Intergation's SFTP with Outbound Channel Adapter for uploading files to a remote location. It works fine when it is sending files to one SFTP location. However, in my code, I am trying to send to multiple SFTP location based on different criteria.

The following is my set up - following from Spring Intergation doc

<beans:bean id="sftpSessionFactory"
    class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
    <beans:property name="host" value="localhost"/>
    <beans:property name="password" value="password"/>
    <beans:property name="port" value="22"/>
    <beans:property name="user" value="user"/>
</beans:bean>

<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter"
    session-factory="sftpSessionFactory"
    channel="outputChannel"
    remote-directory="foo/bar"
    use-temporary-filename="false"
    mode="REPLACE"/>

My questions are:

  1. Does anyone know how to configure multiple SFTP Session
  2. For the outbound channel adapter, is there any way I can set this up in my code instead of XML, specially, I want to calculate the value for remote-directory.

Thanks

1

1 Answers

0
votes

See the dynamic ftp sample application for a technique to do what you want.

The upcoming 4.2 release (release candidate 1 is now available) has a DelegatingSessionFactory where you can dynamically look up the session factory to use. See "what's new in 4.2".