Closed liubao68 closed 2 years ago
This is because open feign hard coded for it's own implementation to use delegate when url is provided: https://github.com/spring-cloud/spring-cloud-openfeign/blob/main/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactoryBean.java
work around: do not use feign client governance. set spring.cloud.servicecomb.feign.governance.enabled
to false.
we'll create a PR for spring-cloud-openfeign to track this problem.
or add a Configuration for non load balanced url,
@FeignClient(name = "urlPrice", url = "http://127.0.0.1:9090",
configuration = UrlFeignService.Configuration.class)
public interface UrlFeignService {
@PostMapping("/price")
String getPrice(@RequestParam("id") Long id);
class Configuration {
@Bean
public Client urlFeignServiceClient(LoadBalancerClient loadBalancerClient, HttpClient httpClient,
LoadBalancerClientFactory loadBalancerClientFactory) {
ApacheHttpClient delegate = new ApacheHttpClient(httpClient);
return new FeignBlockingLoadBalancerClient(delegate, loadBalancerClient, loadBalancerClientFactory);
}
}
}
work around(recommend) : we can treat 3rd-party services like normal discovery services. And we can configure simple discovery client to get the URL. This usable will have all governance features provided by spring cloud huawei.
@FeignClient(name = "urlPrice")
public interface UrlFeignService {
@PostMapping("/price")
String getPrice(@RequestParam("id") Long id);
}
spring:
cloud:
discovery:
client:
simple:
order: -100 # add order to make this check before others
instances:
urlPrice:
- host: 127.0.0.1
port: 9090
instanceId: urlPrice01