Network Transport Extension

Network Transport Extension

Extension Description

Implementations for remote communication servers and client transports.

Extension Interfaces

  • org.apache.dubbo.remoting.Transporter
  • org.apache.dubbo.remoting.Server
  • org.apache.dubbo.remoting.Client

Extension Configuration

  1. <!-- Server and client use the same transport implementation -->
  2. <dubbo:protocol transporter="xxx" />
  3. <!-- Server and client use different transport implementations -->
  4. <dubbo:protocol server="xxx" client="xxx" />
  5. <!-- Default settings, used when <dubbo:protocol> does not configure transporter/server/client attributes -->
  6. <dubbo:provider transporter="xxx" server="xxx" client="xxx" />

Known Extensions

  • org.apache.dubbo.remoting.transport.transporter.netty.NettyTransporter
  • org.apache.dubbo.remoting.transport.transporter.mina.MinaTransporter
  • org.apache.dubbo.remoting.transport.transporter.grizzly.GrizzlyTransporter

Extension Example

Maven project structure:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxTransporter.java (implements Transporter interface)
  7. |-XxxServer.java (implements Server interface)
  8. |-XxxClient.java (implements Client interface)
  9. |-resources
  10. |-META-INF
  11. |-dubbo
  12. |-org.apache.dubbo.remoting.Transporter (plain text file, contents: xxx=com.xxx.XxxTransporter)

XxxTransporter.java:

  1. package com.xxx;
  2. import org.apache.dubbo.remoting.Transporter;
  3. public class XxxTransporter implements Transporter {
  4. public Server bind(URL url, ChannelHandler handler) throws RemotingException {
  5. return new XxxServer(url, handler);
  6. }
  7. public Client connect(URL url, ChannelHandler handler) throws RemotingException {
  8. return new XxxClient(url, handler);
  9. }
  10. }

XxxServer.java:

  1. package com.xxx;
  2. import org.apache.dubbo.remoting.transport.transporter.AbstractServer;
  3. public class XxxServer extends AbstractServer {
  4. public XxxServer(URL url, ChannelHandler handler) throws RemotingException{
  5. super(url, handler);
  6. }
  7. protected void doOpen() throws Throwable {
  8. // ...
  9. }
  10. protected void doClose() throws Throwable {
  11. // ...
  12. }
  13. public Collection<Channel> getChannels() {
  14. // ...
  15. }
  16. public Channel getChannel(InetSocketAddress remoteAddress) {
  17. // ...
  18. }
  19. }

XxxClient.java:

  1. package com.xxx;
  2. import org.apache.dubbo.remoting.transport.transporter.AbstractClient;
  3. public class XxxClient extends AbstractClient {
  4. public XxxServer(URL url, ChannelHandler handler) throws RemotingException{
  5. super(url, handler);
  6. }
  7. protected void doOpen() throws Throwable {
  8. // ...
  9. }
  10. protected void doClose() throws Throwable {
  11. // ...
  12. }
  13. protected void doConnect() throws Throwable {
  14. // ...
  15. }
  16. public Channel getChannel() {
  17. // ...
  18. }
  19. }

META-INF/dubbo/org.apache.dubbo.remoting.Transporter:

  1. xxx=com.xxx.XxxTransporter

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)