网络传输扩展-connect方法未生效
shallowFan opened this issue · comments
shallowFan commented
使用自定义的扩展,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
因为只保存连接端口信息,因此,后面采用dubbo的装饰者模式,保证了使用