Reputation: 367
Is that fallback method and actual method should return same return type.
@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)";
}
What I should do to return String from the fallback method reading list
and return some Object from the actual method reliable
?
Upvotes: 0
Views: 447
Reputation: 27058
By definition fallback method means a substitution for real method if something were to happen.
You cannot return different type. It doesn't make any sense.
Hence method signature has to be exactly same with a few exceptions.
Throwable
to get the exception on which fallback was called.Upvotes: 3