我想在负载平衡期间实现区域关联。在日志中,我看到DynamicServerListLoadBalancer
正在使用“”,并且根据行为,它看起来轮询规则处于活动状态。
我创建了自定义配置来覆盖RibbonClientConfiguration
,但它不起作用。这个对吗?
public class CustomConfiguration {
@Autowired
private IClientConfig config;
@Autowired
ServerListFilter<Server> filter;
@Bean
public ILoadBalancer ribbonLoadBalancer(IClientConfig config,
ServerListFilter<Server> filter) {
ZoneAwareLoadBalancer<Server> balancer = new ZoneAwareLoadBalancer<>(config);
balancer.setFilter(filter);
return balancer;
}
@Bean
public ServerListFilter<Server> ribbonServerListFilter(IClientConfig config) {
ZonePreferenceServerListFilter filter = new ZonePreferenceServerListFilter();
filter.initWithNiwsConfig(config);
return filter;
}
}
@Configuration
@RibbonClient(name = "custom", configuration = CustomConfiguration.class)
public class CustomApplicationConfiguration {
}