
订单服务 order-server 调用商品服务 product-server 查询
/**
* 方案5 : 使用 Feign 接口--负载均衡
*/
Product product = productFeignService.get(pid);
项目启动的时候会扫描所有贴有FeignClient注解的服务
@FeignClient(name = "product-service")
public interface IProductFeignService {
@GetMapping("/products/{pid}")
Product get(@PathVariable Long pid);
}
我们此时拥有IP,端口,接口URL,参数,返回值
注册中心返回服务清单 例如(product-service : IP:端口)
从服务清单中获取远程接口后,就可以发起远程调用了