【问题标题】:Add Poller to SFTP Outbound Gateway将轮询器添加到 SFTP 出站网关
【发布时间】:2021-01-26 16:43:10
【问题描述】:

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

<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>

【问题讨论】:

    标签: spring spring-integration sftp


    【解决方案1】:

    任何出站网关都是事件驱动的端点。这不是流程的开始,例如 &lt;int-sftp:inbound-channel-adapter&gt;

    如果真的想定期触发这样的网关,你可以通过“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 命令。因此,或者您需要配置 &lt;int:inbound-channel-adapter &gt; 以使用该远程目录有效负载生成消息,或者仅在网关上为其提供静态表达式,例如 expression="'/myRemoteDir'".

    无论哪种方式,但只能在流程开始时使用轮询通道适配器。否则不会定期触发网关。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-16
      • 2017-07-22
      相关资源
      最近更新 更多