Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCT升级1.6.0-Hoxton.SR12 到 1.7.0-Hoxton.SR12过程中发现 Feign调用无法从配置中心读取动态服务名称 #509

Closed
thomasZhang1982 opened this issue Aug 16, 2022 · 3 comments
Labels
enhancement New feature or request need discuss need discuss

Comments

@thomasZhang1982
Copy link

Java Web工程

原架构环境:主pom构成

dependencyManagement 依赖 spring-boot-dependencies 和 spring-cloud-tencent-dependencies

<spring-boot.version>2.3.12.RELEASE</spring-boot.version>
1.6.0-Hoxton.SR12

spring-cloud-tencent (1.6.0-Hoxton.SR12) + spring boot (2.3.12.RELEASE) + openfeign(2.2.1.RELEASE) + spring-cloud-commons(2.2.1.RELEASE)

升级前的feignclient的使用

@FeignClient(value = "${system.app.feign.service.platform}",
contextId = "${system.app.feign.service.platform}" + PlatformUrlConstant.WEB_ACCOUNT,
configuration = FeignConfiguration.class,
path = "${system.app.feign.service.platform.path}" + PlatformUrlConstant.WEB_ACCOUNT)
public interface AccountFeignService{
}

${system.app.feign.service.platform} 和 ${system.app.feign.service.platform.path} 是从polaris 配置中心读取的配置变量
system.app.feign.service.platform=system-service
system.app.feign.service.platform.path=

原架构 可正常运行 feign可正常调用

升级过程:

  1. 直接升级 SCT 版本升级 将版本号 1.6.0-Hoxton.SR12 修改为 1.7.0-Hoxton.SR12
  2. 启动失败 无法启动 报依赖包的类不存在

java.lang.NoSuchMethodError: feign.Request.requestTemplate()Lfeign/RequestTemplate;
at com.tencent.cloud.rpc.enhancement.feign.plugin.reporter.ReporterUtils.createServiceCallResult(ReporterUtils.java:43)
at com.tencent.cloud.rpc.enhancement.feign.plugin.reporter.SuccessPolarisReporter.run(SuccessPolarisReporter.java:72)
at com.tencent.cloud.rpc.enhancement.feign.EnhancedFeignClient.execute(EnhancedFeignClient.java:108)
at org.springframework.cloud.openfeign.ribbon.FeignLoadBalancer.execute(FeignLoadBalancer.java:93)
at org.springframework.cloud.openfeign.ribbon.FeignLoadBalancer.execute(FeignLoadBalancer.java:56)
at com.netflix.client.AbstractLoadBalancerAwareClient$1.call(AbstractLoadBalancerAwareClient.java:104)
at com.netflix.loadbalancer.reactive.LoadBalancerCommand$3$1.call(LoadBalancerCommand.java:303)
at com.netflix.loadbalancer.reactive.LoadBalancerCommand$3$1.call(LoadBalancerCommand.java:287)
at rx.internal.util.ScalarSynchronousObservable$3.call(ScalarSynchronousObservable.java:231)
at rx.internal.util.ScalarSynchronousObservable$3.call(ScalarSynchronousObservable.java:228)

升级失败 重新修改主pom依赖架构 升级为

dependencyManagement 依赖 spring-cloud-dependencies 和 spring-cloud-tencent-dependencies

    <!-- Spring Cloud Tencent -->
    <spring.cloud.tencent.version>1.7.0-Hoxton.SR12</spring.cloud.tencent.version>

    <!-- Spring Cloud -->
    <spring.cloud.version>Hoxton.SR12</spring.cloud.version>

spring-cloud-tencent (1.7.0-Hoxton.SR12) + spring cloud (Hoxton.SR12)

从而openFeign 和 spring-cloud-commons使用 spring-cloud依赖的版本 见如下 注释掉了版本号

org.springframework.cloud spring-cloud-starter-openfeign org.springframework.cloud spring-cloud-commons

然后重新启动服务发现报错:
[2022-08-16 10:28:06.159] ERROR org.springframework.boot.SpringApplication 834 - Application run failed
java.lang.IllegalStateException: Service id not legal hostname (${system.app.feign.service.platform}/pla/account)
at org.springframework.util.Assert.state(Assert.java:76)
at org.springframework.cloud.openfeign.FeignClientsRegistrar.getName(FeignClientsRegistrar.java:109)

查看pom依赖树发现 spring-cloud-starter-openfeign 依赖版本为 2.2.9.RELEASE (从spring-cloud Hoxton.SR12依赖)

由此确认 高版本的openfeign 无法读取 配置中心定义的 动态服务名变量

原先不升级架构 单独将 spring-cloud-starter-openfeign 升级到 2.2.1.RELEASE 以上版本 也发现了无法从配置中心读取变量值

期望:
SCT后期版本 能否有改良的feign 支持服务名 可以从配置中心动态获取

@thomasZhang1982 thomasZhang1982 added the bug Something isn't working label Aug 16, 2022
@SkyeBeFreeman SkyeBeFreeman added enhancement New feature or request need discuss need discuss and removed bug Something isn't working labels Aug 18, 2022
@SkyeBeFreeman
Copy link
Collaborator

需要讨论 Feign 版本变更带来的影响。

@dongyinuo
Copy link
Contributor

这个问题 不是 sct 的问题,是 fegin 的问题

问题定位

  1. idea diff (红框为新增代码)

image

2. 通过 git diff 对比 2.2.1 vs 2.2.9 可以看到具体改动

image

问题引入是为了解决 本地测试

spring-cloud/spring-cloud-openfeign#455
spring-cloud/spring-cloud-contract#1303

@dongyinuo
Copy link
Contributor

已给 openfeign 提 issue
spring-cloud/spring-cloud-openfeign#781

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request need discuss need discuss
Projects
None yet
Development

No branches or pull requests

3 participants