栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

[求解决] 启动feign中的hystrix组件遇到问题

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

[求解决] 启动feign中的hystrix组件遇到问题

前景

本人机器全部依赖如下

springboot 2.5.5
springcloud 2020.0.4


    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.5.5
         
    
    com.example.springcloud
    book
    0.0.1-SNAPSHOT
    book
    Demo project for Spring Boot
    
        1.8
        2020.0.4
    
    
        
            org.springframework.boot
            spring-boot-starter-data-jpa
        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.springframework.cloud
            spring-cloud-starter-config
        
        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-client
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
            org.springframework.cloud
            spring-cloud-starter-bootstrap
            3.0.2
        
        
            org.springframework.cloud
            spring-cloud-starter-openfeign
        
        
            org.springframework.cloud
            spring-cloud-starter-netflix-hystrix
            2.2.1.RELEASE
        
        
            org.springframework.cloud
            spring-cloud-config-client
        
      



遇到的问题

使用openfeign的Hytrix断路器配置无效,无法降级。

问题初步排查
# 启动feign中的hystrix组件
feign:
  circuitbreaker:  //springcloud 2020版本应将Hytrix修改为circuitbreaker
    #开启feign的hystrix支持,默认是false  
    enabled: true

springcloud 2020版本应将Hytrix修改为circuitbreaker,我修改后yml文件内报错消失,但是Hytrix功能仍不可用。
后根据网络上添加了netflix-hystrix新依赖,并在主类开启@EnableHystrix
仍不可用。
附上我的业务实现代码

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = "member",fallback = MemberClient.MemberClientFallBack.class)
public interface MemberClient {
    @GetMapping("/check")
    public MemberResult checkMobile(@RequestParam("mobile") String mobile);

    @Component
    static class MemberClientFallBack implements MemberClient{

        @Override
        public MemberResult checkMobile(String mobile) {
            MemberResult mr = new MemberResult();
            mr.setCode("0");
            mr.setMessage("success");
            return mr;
        }
    }
}

目前状况就是无法进入MemberClientFallBack 实现类,实现断路降级功能。
还有一张图附一下,不知道有没有关系,关于Enablecircuitbreker弃用的问题

求教

求路过的各位大佬,不吝赐教!!!不胜感激,我会积极回复消息,并提供补充。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/274936.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号