slankka commented on issue #15040:
URL: https://github.com/apache/dubbo/issues/15040#issuecomment-3580646126

   # Fix No Provider available in some case
   
   Version: dubbo 3.2.6
   
   ## Base case:
   ```java 
       RegistryConfig hzRegistry = new 
RegistryConfig("nacos://127.0.0.2:8848?group=DUBBO");
   
       ReferenceConfig<DemoService> reference = new ReferenceConfig<>();
       reference.setInterfaceClass(DemoService.class);
       reference.setVersion("1.0");
       reference.setRegistry(hzRegistry)
   
        DemoService refer = refercence.get();
        refer.hello();
   ```
   
   ## ConfigCenterAdded
   ```java
   ConfigCenterConfig configCenter = new ConfigCenterConfig();
   configCenter.setAddress("nacos://127.0.0.2:8848?group=DUBBO");
   
reference.getApplicationModel().getConfigManager().addConfigCenter(configCenter)
   ```
   
   ## JVM property set
   ```java
   System.setProperty("dubbo.registry.address", 
"nacos://127.0.0.2:8848?group=DUBBO");
    
   ReferenceConfig<DemoService> reference = new ReferenceConfig<>();
   reference.setInterfaceClass(DemoService.class);
   reference.setVersion("1.0");
   
   DemoService refer = refercence.get();
   refer.hello();
   ```
   
   ## Bootstrap
   ```
     RegistryConfig hzRegistry = new 
RegistryConfig("nacos://127.0.0.2:8848?group=DUBBO");
   
     ReferenceConfig<GreetingsService> reference =
               ReferenceBuilder.<GreetingsService>newBuilder()
               .interfaceClass(GreetingsService.class)
               .version("1.0")
               .build();
       DubboBootstrap.getInstance()
          .reference(reference)
          .registry(hzRegistry)
          .configCenter(configCenter) //add or absent
          .start();
       GreetingsService service = reference.get();
       service.greeting();
   ```
   
   
   ## Conclustion
   
   |Case| Key| Result |
   |-----|-----|------|
   |Base case |  ERR | No Provider available |
   |Base case + ConfigCenterAdded| OK| OK|
   |JVM property set| OK| OK|
   |Bootstrap: ConfigCenter: absent | ERR | No Provider available|
   |Bootstrap + ConfigCenter: Added| OK | OK|
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to