首页 > 解决方案 > Hystrix 在调用 fallback 后不会终止线程

问题描述

我正在使用 Chaos Monkey Spring Boot 测试一个假装客户端的缓慢响应。回退被调用并返回响应,但方法执行继续。

logger.info("Get the value from the organization ms {}",Thread.currentThread().getName());
organizationDTO = organizationRemoteData.getRemoteOrgData(organizationId); // 1
logger.info("saving data in cache {} by {}", organizationDTO,Thread.currentThread().getName());
// saving data in redis
cacheOrganizationObject(organizationDTO);
return organizationDTO;

第 1 行失败并调用了回退,但我仍然在日志中看到“将数据保存在缓存中”。此行为使应用程序不一致。有什么解决方法吗?

日志:

Get the value from the organization ms hystrix-organizationThreadPool-1
calling fallback method to get the organization data for id 1
saving data in cache OrganizationDTO [] by hystrix-organizationThreadPool-1

标签: spring-boothystrixfallbackspring-cloud-feignspring-boot-chaos-monkey

解决方案


推荐阅读