合并结果扩展

扩展说明

合并返回结果,用于分组聚合。

扩展接口

com.alibaba.dubbo.rpc.cluster.Merger

扩展配置

  1. <dubbo:method merger="xxx" />

已知扩展

  • com.alibaba.dubbo.rpc.cluster.merger.ArrayMerger
  • com.alibaba.dubbo.rpc.cluster.merger.ListMerger
  • com.alibaba.dubbo.rpc.cluster.merger.SetMerger
  • com.alibaba.dubbo.rpc.cluster.merger.MapMerger

    扩展示例

Maven 项目结构:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxMerger.java (实现Merger接口)
  7. |-resources
  8. |-META-INF
  9. |-dubbo
  10. |-com.alibaba.dubbo.rpc.cluster.Merger (纯文本文件,内容为:xxx=com.xxx.XxxMerger)

XxxMerger.java:

  1. package com.xxx;
  2. import com.alibaba.dubbo.rpc.cluster.Merger;
  3. public class XxxMerger<T> implements Merger<T> {
  4. public T merge(T... results) {
  5. // ...
  6. }
  7. }

META-INF/dubbo/com.alibaba.dubbo.rpc.cluster.Merger:

  1. xxx=com.xxx.XxxMerger

原文: http://dubbo.apache.org/#!/docs/dev/impls/merger.md?lang=zh-cn