如何从一个轮询器触发多个 ftp 入站通道适配器以连接 ftp 服务器?

how to trigger many ftp inbound-channel-adapter from one poller to connect ftp server?

首先感谢您的关注 我在我的 spring 集成项目中定义了两个 ftp inbound-channel-adapter,具有不同配置但共享会话工厂来连接 ftp 服务器的适配器,每个适配器都有一个轮询器来触发,我想看看波纹管代码是否正确? 是效率?

<bean id="ftpClientFactory"
          class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
        <property name="host" value="127.0.0.1"/>
        <property name="port" value="21"/>
        <property name="username" value="banks_reader"/>
        <property name="password" value="123456"/>

    </bean>
    <bean id="myFilter" class="com.ali.util.FtpFilter"/>
    <bean id="onceFilter" class="com.ali.util.OnceFilter"/>
    <int-ftp:inbound-channel-adapter id="ftpInbound1"
                                     channel="inboundFileChannel"
                                     **session-factory="ftpClientFactory"**
                                     charset="UTF-8"
                                     auto-create-local-directory="true"
                                     delete-remote-files="true"
                                     remote-directory="/directoryA"
                                     remote-file-separator="/"
                                     temporary-file-suffix=".writing"
                                     local-filter="myFilter"
                                     filter="onceFilter"
                                     local-directory="file:output">
        **<int:poller fixed-rate="5000"/>**
</int-ftp:inbound-channel-adapter>
    <int-ftp:inbound-channel-adapter id="ftpInbound2"
                                     channel="inboundFileChannel"
                                     **session-factory="ftpClientFactory"**
                                     charset="UTF-8"
                                     auto-create-local-directory="true"
                                     delete-remote-files="true"
                                     remote-directory="/directoryB"
                                     remote-file-separator="/"
                                     temporary-file-suffix=".writing"
                                     local-filter="myFilter"
                                     filter="onceFilter"
                                     local-directory="file:output">
        **<int:poller fixed-rate="5000"/>**
</int-ftp:inbound-channel-adapter>

还有其他方法吗?

这是使用通道适配器的正确方法。

或者,您可以改用 outbound gateway,并依次从两个目录中获取(ls + getmget)文件。