Is really necessary to use Hystrix with reactive spring boot 2 application?

巧了我就是萌 提交于 2019-12-21 06:18:53

问题


I'm working in a project in which we are moving some of ours microservices from Spring-MVC to Spring-Webflux to test the reactive paradigm. Looking for some help in the github repository of hystrix we've noted that the project have no commits since a year ago, and it's based in RxJava, so there are some incompatibilities with project-reactor.

We're having some issues using Hystrix, particulary that the annotations from "Javanica" doesn't work and our developers need to use HystrixCommands from Spring-Cloud instead. And the fact that Hystrix, obviously, creates his own pool of threads aside from the ones of reactor.

Reached this point my question is not how to use Hystrix with Spring Boot 2.0 but if it's a must to wrap all the external calls from our microservices in an HystrixCommand or if simply using the Reactor methods (timeout, onError, retry, etc.) we can avoid this wrapping.


回答1:


You could replace many of hystrix features with built-in Reactor methods (timeout, retry, limitRate, onError...).

For circuit breaker you could use Resilience4j. It is easy to embed it into existent Reactor code

Mono<MyClass> myMono = ...;
CircuitBreaker circuitBreaker = ...;
myMono.transform(CircuitBreakerOperator.of(circuitBreaker)).subscribe(...)


来源:https://stackoverflow.com/questions/53282413/is-really-necessary-to-use-hystrix-with-reactive-spring-boot-2-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!