Open cl900503 opened 2 years ago
配置不同策略的Bean(同一个服务)
@Configuration public class ReferenceConfiguration { @Bean @DubboReference(interfaceClass = IdGeneratorService.Iface.class, version = "1.0", timeout = 5000, cluster = "hint") public ReferenceBean<IdGeneratorService.Iface> idGeneratorService1() { return new ReferenceBean<IdGeneratorService.Iface>(); } @Bean @DubboReference(interfaceClass = IdGeneratorService.Iface.class, version = "1.0", timeout = 5000, cluster = ClusterRules.BROADCAST) public ReferenceBean<IdGeneratorService.Iface> idGeneratorService2() { return new ReferenceBean<IdGeneratorService.Iface>(); }
}
2. 注入Bean ``` java @Autowired private IdGeneratorService.Iface idGeneratorService1;//idGeneratorService1:hint模式,可以指定ip和port @Autowired private IdGeneratorService.Iface idGeneratorService2;//idGeneratorService2:广播模式 ... ... HintManager.setHint("192.168.0.81", 11251); idGeneratorService1.getId(11); idGeneratorService2.getId(1);
这个日志目前是无法关闭的,可以提个 PR 加个开关
配置不同策略的Bean(同一个服务)
}