resilience4j: Support The Use Of @CircuitBreaker On Methods That Return A Mono Or Flux

Say I have this simple class in a Spring Boot 2 app

@CircuitBreaker(name = "httpbin")
public class WebClientHttpbinService {

	private WebClient client;

	public WebClientHttpbinService() {
		this.client = WebClient.create("http://httpbin.org");

	}

	public Mono<Map> delay(int seconds) {
		return client.get().uri("/delay/{seconds}", seconds).exchange().flatMap(r -> r.bodyToMono(Map.class)).timeout(Duration.ofSeconds(3));
	}
}

I am finding that even if the delay method times out (theWebClient request takes longer than 3 seconds) that the httpbin circuit breaker does not could that as a failure. This makes sense as the method actually completed successfully in returning the Mono<Map>. So should the @CircuitBreaker annotation not be used with methods that return reactive types?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 24 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Can we just repurpose this one?