Hystrix 后备方法不运行

问题描述 投票:0回答:2

我对关闭的端点进行调用,但是 hystrix 不执行回退方法,并抛出异常:

java.util.concurrent.ExecutionException: org.springframework.web.client.ResourceAccessException: 
I/O error on GET request for "http://localhost:8080/wallet/customers/100/cards/": Conexão recusada (Connection refused); nested exception is java.net.ConnectException: Conexão recusada (Connection refused)

有人知道是否缺少任何配置吗?

我的主要

@EnableCircuitBreaker
@SpringBootApplication
public class WalletPaymentApplication {

    public static void main(String[] args) {
        SpringApplication.run(WalletPaymentApplication.class, args);
    }
}

我的服务:

public PaymentMethodsData setUpPaymentMethods(String customerId) {
    return new PaymentMethodsData(getCardList(customerId));
}

@HystrixCommand(fallbackMethod = "getCardListCircuitBreaker")
public List<SummaryCardData> getCardList(String customerId) {
    return template.getForObject(configureUrl(cardUrl), CardRows.class, customerId).getRows();
}

public List<SummaryCardData> getCardListCircuitBreaker(String customerId){
    return new ArrayList<>();
}
java hystrix spring-cloud-netflix circuit-breaker
2个回答
11
投票

要启用

@HystrixCommand(fallbackMethod = "getCardListCircuitBreaker")
,您必须从另一个 bean 调用您的方法。然后注释就可以正常工作了。


0
投票

如果有人解决了这个问题,请分享,应该如何调用。

© www.soinside.com 2019 - 2024. All rights reserved.