9-9 Feign整合Ribbon
Ribbon整合
先把configuration注掉
把原来注释的方法恢复注释,invokerProviderController方法
我们原来是通过url的形式访问的
把URL也注掉,这样就变成了一个没有访问目标的
重启consumer服务,肯定是无法访问的
http://localhost:7201/sayhello/feign?message=111
ERROR (DirectJDKLog.java:175)- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: com.netflix.client.ClientException: Load balancer does not have available server for client: providerTest] with root cause
com.netflix.client.ClientException: Load balancer does not have available server for client: providerTest
改成eureka里面注册的服务名
重启服务测试
http://localhost:7201/sayhello/feign?message=111
演示负载均衡
复制Provider的
和我们的配置文件对应起来
这里也改成pro-02 然后点击Apply
选择并启动
等服务注册到eureka。 可能会稍微的等一会。
这里之前配置的是轮询的方式
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步