codecamp

Dubbo3 路由拓展

扩展说明

从多个服务提供方中选择一个进行调用。

扩展接口

  • org.apache.dubbo.rpc.cluster.RouterFactory
  • org.apache.dubbo.rpc.cluster.Router

已知扩展

  • org.apache.dubbo.rpc.cluster.router.ScriptRouterFactory
  • org.apache.dubbo.rpc.cluster.router.FileRouterFactory
  • org.apache.dubbo.rpc.cluster.router.condition.config.AppRouterFactory
  • org.apache.dubbo.rpc.cluster.CacheableRouterFactory
  • org.apache.dubbo.rpc.cluster.router.condition.ConditionRouterFactory
  • org.apache.dubbo.rpc.cluster.router.mock.MockRouterFactory
  • org.apache.dubbo.rpc.cluster.router.condition.config.ServiceRouterFactory
  • org.apache.dubbo.rpc.cluster.router.tag.TagRouterFactory

扩展示例

Maven 项目结构:

src
 |-main
    |-java
        |-com
            |-xxx
                |-XxxRouterFactory.java (实现RouterFactory接口)
    |-resources
        |-META-INF
            |-dubbo
                |-org.apache.dubbo.rpc.cluster.RouterFactory (纯文本文件,内容为:xxx=com.xxx.XxxRouterFactory)

XxxRouterFactory.java:

package com.xxx;
 
import org.apache.dubbo.rpc.cluster.RouterFactory;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.RpcException;
 
public class XxxRouterFactory implements RouterFactory {
    public Router getRouter(URL url) {
        // ...
    }
}

META-INF/dubbo/org.apache.dubbo.rpc.cluster.RouterFactory:

xxx=com.xxx.XxxRouterFactory


Dubbo3 集群拓展
Dubbo3 负载均衡扩展
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

介绍与示例

应用级服务发现

动态修改运行态配置项

参考手册

配置中心参考手册

元数据参考手册

API 参考手册

Kubernetes 生命周期对齐探针

在线运维命令参考手册

Telnet 命令参考手册

Maven 插件参考手册

性能优化

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }