aowubulao opened a new issue #9622:
URL: https://github.com/apache/dubbo/issues/9622


   * Dubbo version: 2.7.15(2.7.7测试也存在)
   * nacos version: 2.0.2
   * Operating System version: macos12、centos7
   * Java version: 1.8
   
   **复现**
   
   nacos:重启nacos或者使用新的一个ip启动provider应用
   
   dubbo:
   
   首先新建一个自定义Dispatcher
   
   ```java
   public class TestDispatcher implements Dispatcher {
       public static final String NAME = "test";
       @Override
       public ChannelHandler dispatch(ChannelHandler handler, URL url) {
           return new MessageOnlyChannelHandler(handler, url);
       }
   }
   ```
   
   同时在META-INFO.dubbo中也创建对应文件
   
   在配置中指定:
   
   ```properties
   dubbo.protocol.dispatcher=test
   ```
   
   启动服务后,nacos注册成功,可以看到dispatcher等信息都是成功注册的,同时consumer在nacos上也可以看到
   
   ```json
   {
        "side": "provider",
        "service.name": "ServiceBean:/xxx.xxx.demo.serivce.SayService",
        "methods": "sayHelloByName",
        "release": "2.7.15",
        "deprecated": "false",
        "dubbo": "2.0.2",
        "threads": "5",
        "pid": "77518",
        "interface": "xxx.xxx.demo.serivce.SayService",
        "threadpool": "fixed",
        "generic": "false",
        "corethreads": "5",
        "path": "xxx.xxx.demo.serivce.SayService",
        "protocol": "dubbo",
        "metadata-type": "remote",
        "application": "provider-service",
        "dynamic": "true",
        "category": "providers",
        "dispatcher": "test",
        "anyhost": "true",
        "threadname": "default-thread",
        "timestamp": "1643015362814"
   }
   ```
   
   但是调用服务会失败:
   
   ```
   Failed to invoke the method sayHelloByName in the service 
xxx.xxx.demo.serivce.SayService. No provider available for the service 
xxx.xxx.demo.serivce.SayService from registry 127.0.0.1:8848 on the consumer 
10.179.116.54 using the dubbo version 2.7.15. Please check if the providers 
have been started and registered.
   ```
   
   **如何调用成功**
   
   在配置中修改dispatcher为message,启动服务注册成功后,再将dispatcher改为test,重启服务,consumer便可以成功调用
   
   ```properties
   dubbo.protocol.dispatcher=message
   ```
   
   但是线上k8s等服务ip可能会改变,不可能使用改dispatcher重启等方法让consumer调用
   
   **暂时的解决办法**
   
   将自定义的dispatcher的name定义为dubbo已有的,比如message,覆写该dispatcher,便可以直接调用成功
   
   


-- 
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