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