如何通过 Ribbon 对微服务进行负载均衡(不是 feign)。我有 3 个微服务“M1”、“M2”和“M2_duplication”,“M1”通过 feign 与“M2”通信。我想如果“M2”获得太多流量,请求将被转发到“M2_duplication”。这怎么可能通过@ribbonclient 实现?
聚甲醛 M1:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-ribbon</artifactId>
</dependency>
M1中的feign调用:
//name is taken from Eureka(service registry)
@FeignClient(name = "M1")
public interface M1ServiceClient {
@RequestMapping(method = RequestMethod.GET, value = "/getAllM2")
Map<String, String> getAllM2();
}
应用 M1:
@EnableConfigurationProperties()
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
public class PortefeuilleApplication {
public static void main(String[] args) {
SpringApplication.run(PortefeuilleApplication.class, args);
}
}