Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring integration ftp适配器无法轮询ftp服务器中的文件_Java_Spring_Ftp_Spring Integration - Fatal编程技术网

Java Spring integration ftp适配器无法轮询ftp服务器中的文件

Java Spring integration ftp适配器无法轮询ftp服务器中的文件,java,spring,ftp,spring-integration,Java,Spring,Ftp,Spring Integration,我有一个web应用程序,它通过SpringIntegrationFTP适配器对ftp服务器进行轮询。其基本思想是将服务器上的每个新文件提取到本地。它在我的Windows pc上运行得非常好。一旦ftp服务器上更新了新文件,适配器就会将其提取到本地目录。但是,当应用程序在Linux服务器上运行时,ftp适配器停止工作。它在日志中没有给出错误或异常,但日志文件中缺少来自ftp适配器筛选器的所有调试消息 下面是applilcationContext.xml: <bean id="ftpClien

我有一个web应用程序,它通过SpringIntegrationFTP适配器对ftp服务器进行轮询。其基本思想是将服务器上的每个新文件提取到本地。它在我的Windows pc上运行得非常好。一旦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;
}
公共列表过滤器文件(FTPFile[]文件){
logger.debug(“\n正在筛选ftp文件…”);
列表结果=新建LinkedList();
if(localFolder!=null){
对于(FTPFile文件:files){
//下载具有特定标识符的文件
if(SpreaderFileUtil.checkByIdentifiers(file.getName(),externalId)){
//现在检查是否应该下载此文件
if(SpreaderFileUtil.isDownload(file.getName(),localFolder)){
结果.添加(文件);
} 
}
}
}否则{
logger.warn(“本地文件夹为空,无法筛选任何文件”);
}
返回结果;
}

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

好吧,我来关闭这个暂停的流。我上一个Spring集成项目的诀窍是客户端模式。下面是参考文件。
事实上,在定义DefaultFtpSessionFactory时,默认客户端模式设置为活动。通过将客户端模式设置为被动模式,解决了我的问题。

好吧,我来关闭这个挂起的流。我上一个Spring集成项目的诀窍是客户端模式。下面是参考文件。
事实上,在定义DefaultFtpSessionFactory时,默认客户端模式设置为活动。将客户端模式设置为被动模式解决了我的问题。

您确定日志记录配置正确吗?如果使用log4j,您可以使用
-Dlog4j.debug=true
进行验证。服务器可能会覆盖您的日志引用。通常,任何EE服务器都会选择通过其管理工具(如WebSphere管理控制台或JBOSS
logging.xml
@GaryRussell)进行日志记录配置。谢谢您的评论。嗯,我认为log4j工作得很好。高于调试级别的文件追加器阈值日志消息。如果log4j不能像我预期的那样工作,我没有从ftp服务器上获取任何文件,但事实上至少应该获取三个文件。@ArtemBilan实际上我想说log4j不是问题,因为只有filterFiles方法的日志消息丢失了,其他调试记录器工作正常。所以,可能是服务器上的FTP连接设置不正确?或者没有从该Java服务器到FTP服务器的netwrok访问权限…您确定已正确配置日志记录吗?如果使用log4j,您可以使用
-Dlog4j.debug=true
进行验证。服务器可能会覆盖您的日志引用。通常,任何EE服务器都会选择通过其管理工具(如WebSphere管理控制台或JBOSS
logging.xml
@GaryRussell)进行日志记录配置。谢谢您的评论。嗯,我认为log4j工作得很好。高于调试级别的文件追加器阈值日志消息。如果log4j不能像我预期的那样工作,我没有从ftp服务器上获取任何文件,但事实上至少应该获取三个文件。@ArtemBilan实际上我想说log4j不是问题,因为只有filterFiles方法的日志消息丢失了,其他调试记录器工作正常。所以,可能是服务器上的FTP连接设置不正确?或者,从Java服务器到FTP服务器没有netwrok访问权限……如果您连接到SFTP,最新版本的Spring Integration(撰写本文时为4.3.4)不允许您为DefaultSftpSessionFactory设置ClientMode。我已使用DefaultFtpsSessionFactory成功连接到FTPS,它允许您设置被动客户端模式。谢谢Shawn.X.Du!在连接到SFTP的情况下,最新版本的Spring Integration(撰写本文时为4.3.4)不允许您为DefaultSftpSessionFactory设置ClientMode。我已使用DefaultFtpsSessionFactory成功连接到FTPS,它允许您设置被动客户端模式。谢谢Shawn.X.Du!