apache / dubbo-website

Apache Dubbo documents
https://dubbo.apache.org/
Apache License 2.0
468 stars 789 forks source link

网络传输扩展-connect方法未生效 #2913

Open shallowFan opened 7 months ago

shallowFan commented 7 months ago

使用自定义的扩展,connect方法仍然执行的是NettyTransporter中的connect。 dubbo版本:3.2.10 在META-INF/dubbo/org.apache.dubbo.remoting.Transporter配置了自定义扩展信息 在配置文件中配置了dubbo.protocol.transporter的值为custom 代码如下:

public class CustomTransporter implements Transporter {

    public static final String NAME = "custom";

    @Override
    public RemotingServer bind(URL url, ChannelHandler handler) throws RemotingException {
        System.out.println("CustomTransporter:server "+url);
        RemotingServer server = new NettyServer(url, handler);
        return server;
    }

    @Override
    public Client connect(URL url, ChannelHandler handler) throws RemotingException {
        System.out.println("CustomTransporter:client "+url);
        Client client = new NettyClient(url, handler);
        return client;
    }
}
shallowFan commented 7 months ago

因为只保存连接端口信息,因此,后面采用dubbo的装饰者模式,保证了使用