gpt4 book ai didi

java - Hystrix 回退方法不运行

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:21:42 26 4
gpt4 key购买 nike

我调用一个关闭的端点,但是 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<>();
}

最佳答案

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

关于java - Hystrix 回退方法不运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44391557/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com