Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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
如何在Spring与FTP集成中设置轮询配置(轮询FTP服务器)_Ftp_Spring Integration - Fatal编程技术网

如何在Spring与FTP集成中设置轮询配置(轮询FTP服务器)

如何在Spring与FTP集成中设置轮询配置(轮询FTP服务器),ftp,spring-integration,Ftp,Spring Integration,我正在编写一个连接到FTP服务器的应用程序,以便将文件传输到我的本地计算机。为此,我使用入站通道适配器。启动应用程序后,我会看到所有相关文件都从FTP服务器传输到我的本地目录,直到所有文件最终同步为止(FTP服务器和本地服务器上的文件数相同)。我现在希望每5分钟轮询一次FTP服务器,以检查是否存在任何新文件。我最初认为这将是“固定速率”字段,但它似乎每3秒轮询一次FTP服务器。我是否遗漏了什么 我的配置文件如下所示: <?xml version="1.0" encoding="UTF-8"

我正在编写一个连接到FTP服务器的应用程序,以便将文件传输到我的本地计算机。为此,我使用入站通道适配器。启动应用程序后,我会看到所有相关文件都从FTP服务器传输到我的本地目录,直到所有文件最终同步为止(FTP服务器和本地服务器上的文件数相同)。我现在希望每5分钟轮询一次FTP服务器,以检查是否存在任何新文件。我最初认为这将是“固定速率”字段,但它似乎每3秒轮询一次FTP服务器。我是否遗漏了什么

我的配置文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:int="http://www.springframework.org/schema/integration"
       xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/integration/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd">

    <context:property-placeholder location="classpath:application.properties"/>

    <bean id="ftpSessionFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
        <property name="host" value="${ftp.host}"/>
        <property name="port" value="${ftp.port}"/>
        <property name="username" value="${ftp.username}"/>
        <property name="password" value="${ftp.password}"/>
    </bean>

    <int-ftp:inbound-channel-adapter id="ftpInbound"
                                     channel="ftpChannel"
                                     session-factory="ftpSessionFactory"
                                     filename-pattern="*.xml"
                                     auto-create-local-directory="true"
                                     delete-remote-files="false"
                                     remote-directory="/"
                                     local-directory="ftp-inbound"
                                     local-filter="acceptOnceFilter">

        <int:poller fixed-rate="10000" max-messages-per-poll="-1">
            <int:transactional synchronization-factory="syncFactory" />
        </int:poller>

    </int-ftp:inbound-channel-adapter>

    <bean id="acceptOnceFilter"
          class="org.springframework.integration.file.filters.AcceptOnceFileListFilter" />

    <int:transaction-synchronization-factory id="syncFactory">
        <int:after-rollback expression="@acceptOnceFilter.remove(payload)" />
    </int:transaction-synchronization-factory>

    <bean id="transactionManager"
          class="org.springframework.integration.transaction.PseudoTransactionManager" />

    <int:channel id="ftpChannel">
        <int:queue/>
    </int:channel>
</beans>

您有
固定速率=“10000”
,因此它将每10秒轮询一次。固定速率意味着每10秒轮询一次;如果下载需要7秒,我们将在3、10、10…后再次轮询,直到新文件到达

固定延迟
表示下一次轮询在最后一次轮询完成后的毫秒数内开始

如果要在找不到更多文件时更改轮询速率,可以使用智能轮询器

为方便起见,如该文档中所述,提供了一个
SimpleActiviedMessageSourceAdvice

您有
fixed rate=“10000”
,因此它将每10秒轮询一次。fixed rate意味着每10秒一次;如果下载需要7秒,我们将在3秒内再次轮询,然后是10、10、10…直到新文件到达

固定延迟
表示下一次轮询在最后一次轮询完成后的毫秒数内开始

如果要在找不到更多文件时更改轮询速率,可以使用智能轮询器

为方便起见,如该文档中所述,提供了一个
SimpleActiviedMessageSourceAdvice