启动我们的consumer服务。


这个有个sayHello的方法

刷新页面,默认的就已经是负载均衡了。

http://localhost:7201/sayhello?message=eureka

让restTemplate 具有负载均衡的能力。加上@Loadbalanced注解

restTemplate默认会把字符串hello-service-provider替换成你的服务host+port的形式。

uri还是原来的,正常调用


重启consumer服务


还是轮询的操作,但是代码简化了很多。

到目前为止 serverList基本就完成了。下面就是要玩负载均衡算法了。



结束

相关文章:

  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2021-06-08
  • 2021-08-19
猜你喜欢
  • 2022-02-24
  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2021-07-06
  • 2021-10-07
  • 2022-12-23
相关资源
相似解决方案