将轮询器添加到sftp出站网关

zvokhttg  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(261)

我不确定,但无法将轮询器添加到sftp出站网关。我试过这样做,但我没有运气,它不轮询期间启动,所以我已经创建了一个服务接口,然后只是通过调度调用方法。有更好的方法吗?以下是我所做的一个片段:

<int:channel channel="requestChannel"
    <int:queue />
</int:channel>

<int-sftp:outbound-gateway id="ls"
    auto-startup="true"
    expression="payload"
    request-channel="requestChannel"
    remote-directory="${remote-directory}"
    command-options="-1"
    session-factory="sftpSessionFactory"
    command="ls"
    reply-channel="replyChannel">
    <int:poller fixed-delay="10000" max-messages-per-poll="1"/>
</int-sftp:outbound-gateway>
qvsjd97n

qvsjd97n1#

任何出站网关都是事件驱动的端点。它不是一个流动的开始,例如,在 <int-sftp:inbound-channel-adapter> .
如果真的想定期触发这样一个网关,您可以通过“void”入站通道适配器来模拟它:

<int:inbound-channel-adapter channel="requestChannel" expression="''">
     <int:poller fixed-delay="10000" max-messages-per-poll="1"/>
</int:inbound-channel-adapter>

这个 requestChannel 不能再是队列通道。每次轮询时,有效负载为空的消息将被发送到此通道,并且您的网关将执行其逻辑。但是我看到你用 expression="payload" 要执行的远程目录 LS 命令。所以,或者你需要配置它 <int:inbound-channel-adapter > 生成带有远程dir有效负载的消息,或者在网关上为其提供一个静态表达式,例如。 expression="'/myRemoteDir'" .
不管是哪种方式,但只能在流的开头使用轮询通道适配器。否则,网关将不会定期触发。

相关问题