Information Exchange Extension

Information Exchange Extension

Extension Description

Implement the Request-Response information exchange semantics based on the transport layer.

Extension Interfaces

  • org.apache.dubbo.remoting.exchange.Exchanger
  • org.apache.dubbo.remoting.exchange.ExchangeServer
  • org.apache.dubbo.remoting.exchange.ExchangeClient

Extension Configuration

  1. <dubbo:protocol exchanger="xxx" />
  2. <!-- Default value setting, when <dubbo:protocol> does not configure the exchanger attribute, this configuration is used -->
  3. <dubbo:provider exchanger="xxx" />

Known Extension

org.apache.dubbo.remoting.exchange.exchanger.HeaderExchanger

Extension Example

Maven project structure:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxExchanger.java (implements Exchanger interface)
  7. |-XxxExchangeServer.java (implements ExchangeServer interface)
  8. |-XxxExchangeClient.java (implements ExchangeClient interface)
  9. |-resources
  10. |-META-INF
  11. |-dubbo
  12. |-org.apache.dubbo.remoting.exchange.Exchanger (plain text file, content: xxx=com.xxx.XxxExchanger)

XxxExchanger.java:

  1. package com.xxx;
  2. import org.apache.dubbo.remoting.exchange.Exchanger;
  3. public class XxxExchanger implements Exchanger {
  4. public ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException {
  5. return new XxxExchangeServer(url, handler);
  6. }
  7. public ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
  8. return new XxxExchangeClient(url, handler);
  9. }
  10. }

XxxExchangeServer.java:

  1. package com.xxx;
  2. import org.apache.dubbo.remoting.exchange.ExchangeServer;
  3. public class XxxExchangeServer impelements ExchangeServer {
  4. // ...
  5. }

XxxExchangeClient.java:

  1. package com.xxx;
  2. import org.apache.dubbo.remoting.exchange.ExchangeClient;
  3. public class XxxExchangeClient impelments ExchangeClient {
  4. // ...
  5. }

META-INF/dubbo/org.apache.dubbo.remoting.exchange.Exchanger:

  1. xxx=com.xxx.XxxExchanger

Feedback

Was this page helpful?

Yes No

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