apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.51k stars 26.43k forks source link

对同一个服务注入了不同策略的两个Bean,请求接口时,警告consumers下NodeExists,有办法取消警告吗? #10692

Open cl900503 opened 2 years ago

cl900503 commented 2 years ago
  1. 配置不同策略的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);
AlbumenJ commented 2 years ago

这个日志目前是无法关闭的,可以提个 PR 加个开关