What's the difference between @CircuitBreaker
from spring-retry
and @HystrixCommand
from spring-cloud-starter-netflix-hystrix
?
They both seem to implement the circuit breaker pattern.
And the offical Spring guide is using @HystrixCommand
: https://spring.io/guides/gs/circuit-breaker/
In their example:
@HystrixCommand(fallbackMethod = "reliable")
public String readingList() {
URI uri = URI.create("http://localhost:8090/recommended");
return this.restTemplate.getForObject(uri, String.class);
}
public String reliable() {
return "Cloud Native Java (O'Reilly)";
}
Is equivalent (as far as I can tell) to:
@CircuitBreaker
public String readingList() {
URI uri = URI.create("http://localhost:8090/recommended");
return this.restTemplate.getForObject(uri, String.class);
}
@Recover
public String reliable() {
return "Cloud Native Java (O'Reilly)";
}