gpt4 book ai didi

java - Spring 集成 ftp 适配器无法从 ftp 服务器轮询文件

转载 作者:行者123 更新时间:2023-11-29 03:15:22 24 4
gpt4 key购买 nike

我有一个 Web 应用程序正在通过 spring 集成 ftp 适配器对 ftp 服务器进行轮询。基本思想是将服务器上的每个新文件提取到本地。它在我的 Windows 电脑上运行得非常完美。一旦在 ftp 服务器上更新了新文件,适配器就会将其提取到本地目录。但是,当应用程序在 Linux 服务器上运行时,ftp 适配器停止工作。它在日志中没有给出错误或异常,但日志文件中缺少来自 ftp 适配器过滤器的所有调试消息。

这是applilcationContext.xml:

<bean id="ftpClientFactory"
class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
<property name="host" value="N/A"/>
<property name="username" value="N/A"/>
<property name="password" value="N/A"/>
<property name="port" value="1"/>
</bean>

<int-ftp:inbound-channel-adapter id="ftpInbound"
channel="ftpChannel" session-factory="ftpClientFactory"
auto-create-local-directory="true" delete-remote-files="false"
remote-directory="/" local-directory="/tmp/" filter="fileFilter" auto-startup="true">
<int:poller id="poller"
task-executor="pollerPool" max-messages-per-poll="1000" fixedrate="15000"/>
</int-ftp:inbound-channel-adapter>

<task:executor id="pollerPool" pool-size="5" keep-alive="30" queue-capacity="10000" />

文件管理器定义为:

public List<FTPFile> filterFiles(FTPFile[] files) {
logger.debug("\nFiltering ftp file...");
List<FTPFile> result = new LinkedList<FTPFile>();
if (localFolder != null) {
for (FTPFile file : files) {
// download files with specific identifier
if (SpreaderFileUtil.checkByIdentifiers(file.getName(), externalIds)) {
// now check whether this file should be download or not
if (SpreaderFileUtil.isDownload(file.getName(), localFolder)) {
result.add(file);
}
}
}
} else {
logger.warn("Local folder is NULL, cannot filter for any files ");
}
return result;
}

我在文件管理器中添加了一个记录器用于调试。调试消息显示应用程序在本地 pc 上运行时显示,但在服务器上运行时消失。我检查了 ftp 连接,没有问题。在服务器上,我成功地建立了一个到远程服务器的 ftp 连接并手动获取了一个文件。我不知道如何继续,因为日志中根本没有错误或异常。谁能帮我解决这个问题?提前感谢您的任何建议。

最佳答案

好吧,我来关闭这个挂起的流。我之前的 Spring 集成项目中的技巧是客户端模式。下面是引用文档。 http://docs.spring.io/spring-integration/docs/current/api/org/springframework/integration/ftp/session/AbstractFtpSessionFactory.html#setClientMode-int-事实上,在定义 DefaultFtpSessionFactory 时,默认客户端模式设置为 Activity 。我的问题通过将客户端模式设置为被动模式得到解决。

关于java - Spring 集成 ftp 适配器无法从 ftp 服务器轮询文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27042880/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com