Search code examples
springspring-integrationjava-ee-6applicationcontext

Is there anyway to have multiple SFTP inbound channel in one config file?


I have multiple location from where i have to download those files and then will delete those files or will archive those downloaded files on the remote server. Following is what i want to do but the problem is with little knowledge i don't know either this is possible or not.

ApplicationContext:

<bean id="defaultSftpSessionFactory"
            class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
        <property name="host" value="${sftp.host}"/>
        <property name="user" value="${sftp.username}"/>

        <property name="port" value="${sftp.serverPort}"/>
         <property name="privateKey" value="classpath:IBS_KEYS/id_rsa.txt"/>

         <property name="privateKeyPassphrase" value="${sftp.passphrase}"/>

    </bean>

    <bean id="sftpSessionFactory" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
        <constructor-arg ref="defaultSftpSessionFactory" />

    </bean>

<int-sftp:inbound-channel-adapter id="sftpAdapterAutoCreate"
            session-factory="sftpSessionFactory"
            channel="requestSFTPNODEVChannel"
            filename-pattern="*.*"
            remote-directory="/home/oracle/"
            preserve-timestamp="true"
            local-directory="C:/temp/"
            auto-create-local-directory="true"
            temporary-file-suffix=".writing"
            delete-remote-files="true">
    <int:poller fixed-rate="1000"/>
</int-sftp:inbound-channel-adapter>


 <int-sftp:inbound-channel-adapter id="sftpAdapterAutoCreate"
            session-factory="sftpSessionFactory"
            channel="requestSFTPDKDEVChannel"
            filename-pattern="*.*"
            remote-directory="/home/oracle/Outgoing/"
            preserve-timestamp="true"
            local-directory="C:/temp1/"
            auto-create-local-directory="true"
            temporary-file-suffix=".writing"
            delete-remote-files="true">
    <int:poller fixed-rate="1000"/>
</int-sftp:inbound-channel-adapter>

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

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

Solution

  • Yes, you can have as many adapters as you want, but they need unique ids.