开发者社区 > 云原生 > 正文

接口继承导致Sentinel Feign集成出错

定义了一个MsgApi接口类,然后定义了MsgFeignClient实现MsgApi接口, 调用方DataCenterMessageServiceImpl 代码注入MsgApi类调用时,Sentinel代理无法自动适配出MsgApi的实现类MsgFeignClient来调用导致错误,不使用Sentinel时feignclient可以根据MsgApi自动适配出MsgFeignClient类来调用。 请大神帮看看哈,应该是没有自动获取接口Bean来调用,直接使用了接口调用。 备注: 没有把@FeignClient放在MsgCenterApi接口类上是因为我们MsgCenterApi接口还有controller层的实现类。

重现问题代码:

消息服务: MsgApi接口类:

/** * @description 消息中心API接口 / public interface MsgCenterApi { /* * 保存一条推送到消息中心的消息 */ @PostMapping( "api/msgcenter/v1/push") BusinessResponseEntity saveSubmit(@RequestBody MsgVO requestVO); }

MsgFeignclient实现类:

@FeignClient(name = CommonConst.ServiceNameConst.MESSAGE_SERVICE_NAME, url = CommonConst.ServiceNameConst.MESSAGE_SERVICE_URL, fallbackFactory = MsgCenterFeignClientFallBackFactory.class) @RefreshScope public interface MsgCenterFeignClient extends MsgCenterApi { }

合并服务调用类:

@Service public class DataCenterMessageServiceImpl { @Autowired private MsgCenterApi msgCenterApi;

    private void sendMsgToMsgCenter(MsgVO msgVO) {
	 msgCenterApi.saveSubmit(msgVO);
}

原提问者GitHub用户wangjihong-china

展开
收起
码字王 2023-05-19 17:09:36 97 0
1 条回答
写回答
取消 提交回答
  • 参考这个:https://github.com/alibaba/spring-cloud-alibaba/issues/626

    已经升级并修复了。

    原回答者GitHub用户fangjian0423

    2023-05-19 21:15:34
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
阿里邮箱—安全高效集成 立即下载
集成智能接入网关APP:优化企业级移动办公网络 立即下载
云效助力企业集成安全到DevOps中 立即下载