2

我定义了 ftp 适配器来连接到 ftp 服务器,但是我看到了 ftp 服务器日志并且没有看到发送到 ftp 服务器的请求。我的适配器代码是:

<bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
    <property name="host" value="127.0.0.1"/>
    <property name="port" value="21"/>
    <property name="username" value="banks_reader"/>
    <property name="password" value="123456"/>
    <property name="clientMode" value="2"/>
    <property name="fileType" value="2"/>

</bean>


<int:channel id="inbound1">
    <int:queue/>
</int:channel>
<int:channel id="outbound"/>
<int-ftp:outbound-gateway id="gateway1"
                          session-factory="ftpClientFactory"
                          request-channel="inbound1"
                          reply-channel="outbound"
                          reply-timeout="777"
                          auto-create-local-directory="false"
                          auto-startup="true"
                          filename-pattern="*"
                          remote-file-separator="/"
                          command="ls"
                          command-options="-1 -f"
                          expression="payload"
                          order="1"
                          mput-regex=".*">
    <int:poller fixed-delay="1000"/>
</int-ftp:outbound-gateway>

这表明:

DEBUG PollingConsumer:208 - Received no Message during the poll, returning 'false' in application log

当更改用户名和密码进行测试时(假通行证和用户名)不改变任何东西并抛出异常

4

1 回答 1

1

你的配置看起来不错,但你有点错过了一个方法。 <int-ftp:outbound-gateway>是一个事件驱动的请求/回复组件,它不能对 FTP 做任何事情,message直到inbound1. 即使是<queue><poller>也只有在没有那个的情况下才会启动它的工作Received no Message during the poll

由于您使用expression="payload",因此您requestMessage必须包含来自您的 FTP 用户主页的payloadwith 。remote dir

所以,只需发送这样的消息给inbound1我们,让我们知道它是怎么回事!

更新

要定期使用与 a 相同的命令执行LS命令,您必须配置如下内容:<int-ftp:outbound-gateway>dirpayload

<inbound-channel-adapter channel="inbound1" expresssion="'/'">
    <poller fixed-delay="10000"/>
</inbound-channel-adapter>

有了那个(和你的<gateway>)案例,就不需要将该inbound1频道作为<queue>

于 2015-04-19T16:16:09.453 回答