1

我正在尝试学习和实现 hystrix 断路器。我使用了下面提到的代码。

 @Component
 public class Utils{

 @HystrixCommand(fallbackMethod = "readingList")
 public String getResponse(String restURL, String b){

    //get call to another micro serice
 CustomeReponse clientResponse=  restClient.get(restURL, MediaType.APPLICATION_JSON);

    return clientResponse;
}

@HystrixCommand
public String  readingList(String restURL, String b) {
    System.out.println("hello");
    return null;
}

每当对另一个微服务进行 get 调用时,应用程序都会抛出异常。而它应该执行 fallbackMethod 方法。我究竟做错了什么?

4

0 回答 0