使用 Reactor 限制请求率 [英] Limiting rate of requests with Reactor

查看:47
本文介绍了使用 Reactor 限制请求率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用项目反应器从使用休息的 Web 服务加载数据.这是与多个线程并行完成的.我开始达到 Web 服务的速率限制,因此我希望每秒最多发送 10 个请求以避免出现这些错误.我将如何使用反应器做到这一点?

I'm using project reactor to load data from a web service using rest. This is done in parallel with multiple threads. I'm starting to hit rate limits on the web service, so I would like to send at most 10 requests per second to avoid getting these errors. How would I do that using reactor?

使用 zipWith(Mono.delayMillis(100))?或者有什么更好的方法?

Using zipWith(Mono.delayMillis(100))? Or is there some better way?

谢谢

推荐答案

您可以使用 delayElements 而不是整个 zipwith.

You can use delayElements instead of the whole zipwith.

这篇关于使用 Reactor 限制请求率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆