Spring Integration: Poll HTTP

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-07 03:58:06

问题


How can I poll a HTTP web service using Spring Integration.

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

The http outbound gateway doesn't support poller like the Twitter one.

Of course there is the possibility to create a dummy gateway to send empty messages and to configure this using a task scheduler.


回答1:


Actually it is a pretty clean and nice solution to create an inbound-channel-adapter, like this

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

The above one will automatically start(default behavior, anyway) and poll every 30 seconds.



来源:https://stackoverflow.com/questions/20360020/spring-integration-poll-http

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!