在 Java Springboot 中减慢发送给第三方的请求间隔?
Slowing down the interval of requests sent to a third party in Java Springboot?
我在 Java Springboot 中构建了一个 API。我需要减慢从我的 API 发送给第三方的请求的间隔。什么是延迟从 Java Springboot API 发送的多个请求以便以毫秒为间隔发送的好策略?
向您的 API 添加一个队列,每次收到请求时不要将其发送给 3d 派对 API,而是将其写入您的队列。 运行 您从 ScheduledThreadPoolExecutor 开始的那个队列的消费者,时间间隔是您需要的。
请查看 Resilience4j 图书馆。该库旨在帮助您完成您想做的事情。
他们网站上的描述,重点是我的。
Resilience4j is a lightweight fault tolerance library inspired by Netflix Hystrix, but designed for functional programming.
Resilience4j provides higher-order functions (decorators) to enhance any functional interface, lambda expression or method reference with a Circuit Breaker, Rate Limiter, Retry or Bulkhead. You can stack more than one decorator on any functional interface, lambda expression or method reference. The advantage is that you have the choice to select the decorators you need and nothing else.
Guide to Resilience4j,来自 Baeldung 的教程。
您要查找的技术术语是 Throttle。
我在 Java Springboot 中构建了一个 API。我需要减慢从我的 API 发送给第三方的请求的间隔。什么是延迟从 Java Springboot API 发送的多个请求以便以毫秒为间隔发送的好策略?
向您的 API 添加一个队列,每次收到请求时不要将其发送给 3d 派对 API,而是将其写入您的队列。 运行 您从 ScheduledThreadPoolExecutor 开始的那个队列的消费者,时间间隔是您需要的。
请查看 Resilience4j 图书馆。该库旨在帮助您完成您想做的事情。
他们网站上的描述,重点是我的。
Resilience4j is a lightweight fault tolerance library inspired by Netflix Hystrix, but designed for functional programming. Resilience4j provides higher-order functions (decorators) to enhance any functional interface, lambda expression or method reference with a Circuit Breaker, Rate Limiter, Retry or Bulkhead. You can stack more than one decorator on any functional interface, lambda expression or method reference. The advantage is that you have the choice to select the decorators you need and nothing else.
Guide to Resilience4j,来自 Baeldung 的教程。
您要查找的技术术语是 Throttle。