Spring Integration HTTP request throttling

北战南征 提交于 2019-12-13 21:28:25

问题


Looking to implement http request throttle limits and wondering if Poller is the option or should Interceptor be used? The idea is have a rule of "X number of requests/operations in Y amount of time" and it should work across the cluster.


回答1:


It depends on what you want to do to the throttled caller; throw an exception (after some timeout) or wait forever. Using a queue channel after the gateway (with a limit and a send-timeout on the gateway) would work, and throw an exception if the time exceeded; setting the timeout to -1 (default) would block forever.

You can catch the exception via an error-channel on the gateway and return a friendly "too busy" reply (if you timeout).

An interceptor could probably be crafted to be more sophisticated - a rate limit Vs. a simple queue limit.



来源:https://stackoverflow.com/questions/24046737/spring-integration-http-request-throttling

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