spring-integration - FTP 入站 channel 适配器的 FTP 问题

标签 spring-integration

我们的项目我们正在使用 ftp:inbound-channel-adapter 从 FTP 服务器轮询文件。它工作正常。但在轮询之间没有工作。当我看到 FTP 服务器日志时,我看到“425 无法打开数据连接.”现在,当我重新启动或停止并再次启动 ftp:inbound-channel-adapter 时,其轮询正常。此问题反复发生以解决我需要停止/启动 ftp:inbound-channel-adapter.ftp:inbound-channel-adapter在 linux 操作系统中运行。

我正在使用 spring-integration 3 只是为了更清楚我已经包含了 xsd 信息
(spring-integration-3.0.xsd,spring-integration-ftp-3.0.xsd)

是否需要为 FTP 设置任何特定的客户端模式,即主动(本地/远程)/被动(本地/远程)等?
在我的 ftp:inbound-channel-adapter 配置下方

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

<int-ftp:inbound-channel-adapter id="ftpInbound"
                channel="ftpChannel"
                session-factory="ftpClientFactory"
                auto-create-local-directory="true"
                delete-remote-files="true"
                remote-directory="/"  
                local-filename-generator-expression="new java.text.SimpleDateFormat('yyyy-MM-dd-hhmmssSSS').format(new java.util.Date()) + '.'+ #this"  
                local-directory="${ftp.sync.folder}"
                remote-file-separator="/">
    </int-ftp:inbound-channel-adapter>

所以不确定我可以在 FTP 服务器上做些什么。但我想看看 ftp:inbound-channel-adapter 中是否有任何选项或您建议的任何内容,以便每当 FTP 服务器抛出“425 无法打开数据连接。 ”而不是手动停止/启动 ftp:inbound-channel-adapter 是否有任何选项或自动方式来完成这项工作。谢谢

添加了有关 spring 集成版本和 ftp session 工厂的信息。

最佳答案

有主动和被动模式连接到 FTP 服务器的 2 种方式。

ActiveMode : FTP 服务器必须与客户端提到的端口建立数据连接
(如果端口被防火墙阻止,则会出现防火墙问题,您将收到 425 数据连接错误)

被动模式:客户端必须与 FTP 服务器提到的端口建立数据连接。
(客户端没有fairwall问题。此外,我们可以在FTP服务器中配置passvieports并使这些端口不被FTP服务器防火墙阻止。)

如果您未在 ftpsessionfactory 中指定任何 clientmode,则默认为 Active 模式,即 clientMode=0。
所以我有防火墙问题,导致 425 数据连接问题。在我关闭防火墙后,它运行良好。所以现在我将我的 FTPsessionfactory 更改为使用 Passivemode,因此 FTP 服务器从不关心客户端防火墙

<bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
        <property name="host" value="abcd.com"/>
        <property name="port" value="21"/>
        <property name="username" value="userid"/>
        <property name="password" value="password"/>
<!-- 2  passive mode -->
<property name="clientMode" value="2"/>
</bean>

这种方式从不关心客户端的防火墙。
关于 FTP 的非常好的帖子 http://slacksite.com/other/ftp.html

关于spring-integration - FTP 入站 channel 适配器的 FTP 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26632577/

相关文章:

java - Spring Batch条件流不执行else部分

java - Spring 集成在有效负载中传递 ImmutableCollection

spring - int-ftp :inbound-channel-adapter fetch in sequential order?

spring - 如何控制并行 Spring Batch 作业的数量

spring-integration - Spring Integration 将有效负载转换为服务激活器中的对象

java - Nilocker 无法在 Spring Boot 应用程序中工作

spring - Jaxb2Marshaller 与 Spring 集成

Java Spring-集成TCP刷新控制

java - Spring Integration DSL JDBC 入站 channel 适配器

spring-integration - JMS 出站网关请求目的地 - 成功后处理