在我们的项目中,我们使用ftp:入站通道适配器从ftp服务器轮询文件。工作正常。但在轮询之间不起作用。当我看到FTP服务器日志时,我看到"425无法打开数据连接"。现在,当我重新启动或停止并再次启动FTP:inbound通道适配器时,它的轮询正常。这个问题反复出现,以解决我需要停止/启动ftp:入站通道适配器的问题。ftp:出站通道适配器正在linux操作系统中运行。
我使用spring integration 3只是为了更清楚地表明我已经包含了xsd信息(spring-integration-3.0.xsd,spring-integration-ftp-3.0.xsd)
我是否需要为FTP设置任何特定的客户端模式,即主动(本地/远程)/被动(本地/远端)等?在我的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"/>
</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:入站通道适配器中有没有任何选项,或者你建议的任何东西,这样每当FTP服务器抛出"425无法打开数据连接"时。有没有任何选择或自动方式来停止/启动FTP:出站通道适配器。感谢
添加了关于spring集成版本和ftp会话工厂的信息。
有两种方式可以连接到FTP服务器主动和被动模式。
ActiveMode:FTP服务器必须与客户端提到的端口进行数据连接(如果端口被防火墙堵塞,防火墙问题,您将得到425数据连接错误)
Passivemode:客户端必须与FTP服务器提到的端口进行数据连接。(客户端没有fairwall问题。此外,我们可以在FTP服务器中配置passvieports,并使这些端口不被FTP服务器防火墙阻止。)
如果您没有在ftpsessionfactory中指定任何客户端模式,则默认为活动模式,即客户端模式=0。所以我有防火墙问题,导致425数据连接问题。在我关闭防火墙后,它运行良好。所以现在我把我的FTP会话工厂改为使用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