0

Rate limiting on top of WebFlux retry

I want to limit the number of retires from WebFlux. The use case is that if the service to be invoked goes down then i end up retrying for all read timeouts which in-turn creates double the load. I figured out a way to write custom methods for checking the feasibility of retry but that looks to be more of a hack. Is there any cleaner approach to follow for this use case?

  • 1
    have you had a chance to read through the reactor reference documentation? It has a section on the retry operator. https://projectreactor.io/docs/core/release/reference/#_retrying – Michael McFadyen Mar 11 '21 at 19:46
  • @MichaelMcFadyen It could be clearer, but I believe the question is asking about how to make sure retries to a single service are limited across *all* publishers. If so that's not so trivial (the retry operator only provides semantics for controlling retries on an individual publisher level.) – Michael Berry Mar 12 '21 at 10:19
  • @NitinSaxena Could you update your question to clarify? – Michael Berry Mar 12 '21 at 11:58

1 Answers1

0

Based on the question tags, you already figured out what you need: circuit breaker.

Resilience4j circuit breaker has support for Project Reactor: https://resilience4j.readme.io/docs/examples-1#decorate-flowable-with-a-circuitbreaker

Martin Tarjányi
  • 8,863
  • 2
  • 31
  • 49