【问题标题】:Spring Integration: Poll HTTPSpring 集成:轮询 HTTP
【发布时间】:2013-12-03 19:33:17
【问题描述】:

如何使用 Spring Integration 轮询 HTTP Web 服务。

<int-http:outbound-gateway request-channel="in" reply-channel="out"
    url="http://whatever.com" http-method="GET" 
    expected-response-type="java.lang.String"/>

http 出站网关不支持像 Twitter 那样的轮询器。

当然可以创建一个虚拟网关来发送空消息并使用任务调度程序进行配置。

【问题讨论】:

    标签: java spring spring-integration


    【解决方案1】:

    实际上,像这样创建inbound-channel-adapter 是一个非常干净且不错的解决方案

    <int:inbound-channel-adapter id="in" expression="''" auto-startup="true" >
        <int:poller cron="* */30 * * * *" max-messages-per-poll="3" />
    </int:inbound-channel-adapter>
    

    上面的会自动启动(无论如何都是默认行为)并每 30 秒轮询一次。

    【讨论】:

    • 我不确定您所说的“最多 3 个”是什么意思;这将在每次轮询时向in 发送 3 条背靠背消息 - 它轮询表达式,该表达式始终返回一条消息。
    • 你是对的。我的意思是“与”,但我完全删除了那部分。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-06
    • 2017-10-26
    • 2020-10-28
    • 1970-01-01
    • 2014-02-16
    • 1970-01-01
    • 2017-02-16
    相关资源
    最近更新 更多