消息派发扩展

扩展说明

通道信息派发器,用于指定线程池模型。

扩展接口

org.apache.dubbo.remoting.Dispatcher

扩展配置

  1. <dubbo:protocol dispatcher="xxx" />
  2. <!-- 缺省值设置,当<dubbo:protocol>没有配置dispatcher属性时,使用此配置 -->
  3. <dubbo:provider dispatcher="xxx" />

已知扩展

  • org.apache.dubbo.remoting.transport.dispatcher.all.AllDispatcher
  • org.apache.dubbo.remoting.transport.dispatcher.direct.DirectDispatcher
  • org.apache.dubbo.remoting.transport.dispatcher.message.MessageOnlyDispatcher
  • org.apache.dubbo.remoting.transport.dispatcher.execution.ExecutionDispatcher
  • org.apache.dubbo.remoting.transport.dispatcher.connection.ConnectionOrderedDispatcher

扩展示例

Maven 项目结构:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxDispatcher.java (实现Dispatcher接口)
  7. |-resources
  8. |-META-INF
  9. |-dubbo
  10. |-org.apache.dubbo.remoting.Dispatcher (纯文本文件,内容为:xxx=com.xxx.XxxDispatcher)

XxxDispatcher.java:

  1. package com.xxx;
  2. import org.apache.dubbo.remoting.Dispatcher;
  3. public class XxxDispatcher implements Dispatcher {
  4. public Group lookup(URL url) {
  5. // ...
  6. }
  7. }

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

  1. xxx=com.xxx.XxxDispatcher