| |
| <!DOCTYPE HTML> |
| <html lang="" > |
| <head> |
| <meta charset="UTF-8"> |
| <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> |
| <title>11 推荐用法 · GitBook</title> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
| <meta name="description" content=""> |
| <meta name="generator" content="GitBook 3.2.2"> |
| |
| |
| |
| |
| <link rel="stylesheet" href="gitbook/style.css"> |
| |
| |
| |
| |
| <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css"> |
| |
| |
| |
| <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css"> |
| |
| |
| |
| <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <meta name="HandheldFriendly" content="true"/> |
| <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
| <meta name="apple-mobile-web-app-capable" content="yes"> |
| <meta name="apple-mobile-web-app-status-bar-style" content="black"> |
| <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png"> |
| <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon"> |
| |
| |
| <link rel="next" href="capacity-plan.html" /> |
| |
| |
| <link rel="prev" href="best-practice.html" /> |
| |
| |
| </head> |
| <body> |
| |
| <div class="book"> |
| <div class="book-summary"> |
| |
| |
| <div id="book-search-input" role="search"> |
| <input type="text" placeholder="Type to search" /> |
| </div> |
| |
| |
| <nav role="navigation"> |
| |
| |
| |
| <ul class="summary"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <li class="chapter " data-level="1.1" data-path="./"> |
| |
| <a href="./"> |
| |
| |
| Introduction |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.2" > |
| |
| <span> |
| |
| |
| 1 入门 |
| |
| </span> |
| |
| |
| |
| <ul class="articles"> |
| |
| |
| <li class="chapter " data-level="1.2.1" data-path="preface/background.html"> |
| |
| <a href="preface/background.html"> |
| |
| |
| 1.1 背景 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.2.2" data-path="preface/requirements.html"> |
| |
| <a href="preface/requirements.html"> |
| |
| |
| 1.2 需求 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.2.3" data-path="preface/architacture.html"> |
| |
| <a href="preface/architacture.html"> |
| |
| |
| 1.3 架构 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.2.4" data-path="preface/usage.html"> |
| |
| <a href="preface/usage.html"> |
| |
| |
| 1.4 用法 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| |
| </ul> |
| |
| </li> |
| |
| <li class="chapter " data-level="1.3" > |
| |
| <span> |
| |
| |
| 2 快速启动 |
| |
| </span> |
| |
| |
| |
| <ul class="articles"> |
| |
| |
| <li class="chapter " data-level="1.3.1" data-path="dependencies/dependencies.html"> |
| |
| <a href="dependencies/dependencies.html"> |
| |
| |
| 2.1 依赖 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.3.2" data-path="maturity/maturity.html"> |
| |
| <a href="maturity/maturity.html"> |
| |
| |
| 2.2 成熟度 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| |
| </ul> |
| |
| </li> |
| |
| <li class="chapter " data-level="1.4" > |
| |
| <span> |
| |
| |
| 3 配置 |
| |
| </span> |
| |
| |
| |
| <ul class="articles"> |
| |
| |
| <li class="chapter " data-level="1.4.1" data-path="configuration/xml.html"> |
| |
| <a href="configuration/xml.html"> |
| |
| |
| 3.1 XML配置 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.4.2" data-path="configuration/properties.html"> |
| |
| <a href="configuration/properties.html"> |
| |
| |
| 3.2 属性配置 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.4.3" data-path="configuration/api.html"> |
| |
| <a href="configuration/api.html"> |
| |
| |
| 3.3 API配置 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.4.4" data-path="configuration/annotation.html"> |
| |
| <a href="configuration/annotation.html"> |
| |
| |
| 3.4 注解配置 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| |
| </ul> |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5" > |
| |
| <span> |
| |
| |
| 4 示例 |
| |
| </span> |
| |
| |
| |
| <ul class="articles"> |
| |
| |
| <li class="chapter " data-level="1.5.1" data-path="demos/启动时检查.html"> |
| |
| <a href="demos/启动时检查.html"> |
| |
| |
| 4.1 启动时检查 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.2" data-path="demos/集群容错.html"> |
| |
| <a href="demos/集群容错.html"> |
| |
| |
| 4.2 集群容错 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.3" data-path="demos/负载均衡.html"> |
| |
| <a href="demos/负载均衡.html"> |
| |
| |
| 4.3 负载均衡 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.4" data-path="demos/线程模型.html"> |
| |
| <a href="demos/线程模型.html"> |
| |
| |
| 4.4 线程模型 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.5" data-path="demos/直连提供者.html"> |
| |
| <a href="demos/直连提供者.html"> |
| |
| |
| 4.5 直连提供者 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.6" data-path="demos/只订阅.html"> |
| |
| <a href="demos/只订阅.html"> |
| |
| |
| 4.6 只订阅 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.7" data-path="demos/只注册.html"> |
| |
| <a href="demos/只注册.html"> |
| |
| |
| 4.7 只注册 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.8" data-path="demos/静态服务.html"> |
| |
| <a href="demos/静态服务.html"> |
| |
| |
| 4.8 静态服务 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.9" data-path="demos/多协议.html"> |
| |
| <a href="demos/多协议.html"> |
| |
| |
| 4.9 多协议 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.10" data-path="demos/多注册中心.html"> |
| |
| <a href="demos/多注册中心.html"> |
| |
| |
| 4.10 多注册中心 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.11" data-path="demos/服务分组.html"> |
| |
| <a href="demos/服务分组.html"> |
| |
| |
| 4.11 服务分组 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.12" data-path="demos/多版本.html"> |
| |
| <a href="demos/多版本.html"> |
| |
| |
| 4.13 多版本 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.13" data-path="demos/分组聚合.html"> |
| |
| <a href="demos/分组聚合.html"> |
| |
| |
| 4.14 分组聚合 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.14" data-path="demos/参数验证.html"> |
| |
| <a href="demos/参数验证.html"> |
| |
| |
| 4.15 参数验证 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.15" data-path="demos/结果缓存.html"> |
| |
| <a href="demos/结果缓存.html"> |
| |
| |
| 4.16 结果缓存 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.16" data-path="demos/泛化引用.html"> |
| |
| <a href="demos/泛化引用.html"> |
| |
| |
| 4.17 泛化引用 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.17" data-path="demos/泛化实现.html"> |
| |
| <a href="demos/泛化实现.html"> |
| |
| |
| 4.18 泛化实现 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.18" data-path="demos/回声测试.html"> |
| |
| <a href="demos/回声测试.html"> |
| |
| |
| 4.19 回声测试 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.19" data-path="demos/上下文信息.html"> |
| |
| <a href="demos/上下文信息.html"> |
| |
| |
| 4.20 上下文信息 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.20" data-path="demos/隐式参数.md"> |
| |
| <span> |
| |
| |
| 4.21 隐式参数 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.21" data-path="demos/异步调用.html"> |
| |
| <a href="demos/异步调用.html"> |
| |
| |
| 4.22 异步调用 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.22" data-path="demos/本地调用.html"> |
| |
| <a href="demos/本地调用.html"> |
| |
| |
| 4.23 本地调用 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.23" data-path="demos/参数回调.html"> |
| |
| <a href="demos/参数回调.html"> |
| |
| |
| 4.24 参数回调 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.24" data-path="demos/事件通知.html"> |
| |
| <a href="demos/事件通知.html"> |
| |
| |
| 4.25 事件通知 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.25" data-path="demos/本地存根.html"> |
| |
| <a href="demos/本地存根.html"> |
| |
| |
| 4.26 本地存根 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.26" data-path="demos/本地伪装.html"> |
| |
| <a href="demos/本地伪装.html"> |
| |
| |
| 4.27 本地伪装 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.27" data-path="demos/延迟暴露.html"> |
| |
| <a href="demos/延迟暴露.html"> |
| |
| |
| 4.28 延迟暴露 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.28" data-path="demos/并发控制.html"> |
| |
| <a href="demos/并发控制.html"> |
| |
| |
| 4.29 并发控制 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.29" data-path="demos/连接控制.html"> |
| |
| <a href="demos/连接控制.html"> |
| |
| |
| 4.30 连接控制 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.30" data-path="demos/延迟连接.html"> |
| |
| <a href="demos/延迟连接.html"> |
| |
| |
| 4.31 延迟连接 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.31" data-path="demos/粘滞连接.html"> |
| |
| <a href="demos/粘滞连接.html"> |
| |
| |
| 4.32 粘滞连接 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.32" data-path="demos/令牌验证.html"> |
| |
| <a href="demos/令牌验证.html"> |
| |
| |
| 4.33 令牌验证 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.33" data-path="demos/路由规则.html"> |
| |
| <a href="demos/路由规则.html"> |
| |
| |
| 4.34 路由规则 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.34" data-path="demos/配置规则.html"> |
| |
| <a href="demos/配置规则.html"> |
| |
| |
| 4.35 配置规则 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.35" data-path="demos/服务降级.html"> |
| |
| <a href="demos/服务降级.html"> |
| |
| |
| 4.36 服务降级 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.36" data-path="demos/优雅停机.html"> |
| |
| <a href="demos/优雅停机.html"> |
| |
| |
| 4.37 优雅停机 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.37" data-path="demos/主机绑定.html"> |
| |
| <a href="demos/主机绑定.html"> |
| |
| |
| 4.38 主机绑定 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.38" data-path="demos/日志适配.html"> |
| |
| <a href="demos/日志适配.html"> |
| |
| |
| 4.39 日志适配 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.39" data-path="demos/访问日志.html"> |
| |
| <a href="demos/访问日志.html"> |
| |
| |
| 4.40 访问日志 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.40" data-path="demos/服务容器.html"> |
| |
| <a href="demos/服务容器.html"> |
| |
| |
| 4.41 服务容器 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.41" data-path="demos/ReferenceConfig缓存.html"> |
| |
| <a href="demos/ReferenceConfig缓存.html"> |
| |
| |
| 4.42 Reference Config缓存 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.42" data-path="demos/分布式事务.html"> |
| |
| <a href="demos/分布式事务.html"> |
| |
| |
| 4.43 分布式事务 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.5.43" data-path="reference-apiconf/api.html"> |
| |
| <a href="reference-apiconf/api.html"> |
| |
| |
| 5 API参考手册 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| |
| </ul> |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6" data-path="reference-xmlconf/introduction.html"> |
| |
| <a href="reference-xmlconf/introduction.html"> |
| |
| |
| 5 schema配置参考手册 |
| |
| </a> |
| |
| |
| |
| <ul class="articles"> |
| |
| |
| <li class="chapter " data-level="1.6.1" data-path="reference-xmlconf/dubbo-service.html"> |
| |
| <a href="reference-xmlconf/dubbo-service.html"> |
| |
| |
| 5.1 dubbo:service |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6.2" data-path="reference-xmlconf/dubbo-reference.html"> |
| |
| <a href="reference-xmlconf/dubbo-reference.html"> |
| |
| |
| 5.2 dubbo:reference |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6.3" data-path="reference-xmlconf/dubbo-protocol.html"> |
| |
| <a href="reference-xmlconf/dubbo-protocol.html"> |
| |
| |
| 5.3 dubbo:protocol |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6.4" data-path="reference-xmlconf/dubbo-registry.html"> |
| |
| <a href="reference-xmlconf/dubbo-registry.html"> |
| |
| |
| 5.4 dubbo:registry |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6.5" data-path="reference-xmlconf/dubbo-monitor.html"> |
| |
| <a href="reference-xmlconf/dubbo-monitor.html"> |
| |
| |
| 5.5 dubbo:monitor |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6.6" data-path="reference-xmlconf/dubbo-application.html"> |
| |
| <a href="reference-xmlconf/dubbo-application.html"> |
| |
| |
| 5.6 dubbo:application |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6.7" data-path="reference-xmlconf/dubbo-module.html"> |
| |
| <a href="reference-xmlconf/dubbo-module.html"> |
| |
| |
| 5.7 dubbo:module |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6.8" data-path="reference-xmlconf/dubbo-provider.html"> |
| |
| <a href="reference-xmlconf/dubbo-provider.html"> |
| |
| |
| 5.8 dubbo:provider |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6.9" data-path="reference-xmlconf/dubbo-consumer.html"> |
| |
| <a href="reference-xmlconf/dubbo-consumer.html"> |
| |
| |
| 5.9 dubbo:consumer |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6.10" data-path="reference-xmlconf/dubbo-method.html"> |
| |
| <a href="reference-xmlconf/dubbo-method.html"> |
| |
| |
| 5.10 dubbo:method |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6.11" data-path="reference-xmlconf/dubbo-argument.html"> |
| |
| <a href="reference-xmlconf/dubbo-argument.html"> |
| |
| |
| 5.11 dubbo:argument |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.6.12" data-path="reference-xmlconf/dubbo-parameter.html"> |
| |
| <a href="reference-xmlconf/dubbo-parameter.html"> |
| |
| |
| 5.12 dubbo:parameter |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| |
| </ul> |
| |
| </li> |
| |
| <li class="chapter " data-level="1.7" data-path="reference-protocol/introduction.html"> |
| |
| <a href="reference-protocol/introduction.html"> |
| |
| |
| 6 协议参考手册 |
| |
| </a> |
| |
| |
| |
| <ul class="articles"> |
| |
| |
| <li class="chapter " data-level="1.7.1" data-path="reference-protocol/dubbo.html"> |
| |
| <a href="reference-protocol/dubbo.html"> |
| |
| |
| 6.1 dubbo:// |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.7.2" data-path="reference-protocol/rmi.html"> |
| |
| <a href="reference-protocol/rmi.html"> |
| |
| |
| 6.2 rmi// |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.7.3" data-path="reference-protocol/hessian.html"> |
| |
| <a href="reference-protocol/hessian.html"> |
| |
| |
| 6.3 hessian:// |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.7.4" data-path="reference-protocol/http.html"> |
| |
| <a href="reference-protocol/http.html"> |
| |
| |
| 6.4 http:// |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.7.5" data-path="reference-protocol/webservice.html"> |
| |
| <a href="reference-protocol/webservice.html"> |
| |
| |
| 6.5 webservice:// |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.7.6" data-path="reference-protocol/thrift.html"> |
| |
| <a href="reference-protocol/thrift.html"> |
| |
| |
| 6.6 thrift:// |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.7.7" data-path="reference-protocol/memcached.html"> |
| |
| <a href="reference-protocol/memcached.html"> |
| |
| |
| 6.7 memcached:// |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.7.8" data-path="reference-protocol/redis.html"> |
| |
| <a href="reference-protocol/redis.html"> |
| |
| |
| 6.8 redis:// |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| |
| </ul> |
| |
| </li> |
| |
| <li class="chapter " data-level="1.8" data-path="reference-registry/introduction.html"> |
| |
| <a href="reference-registry/introduction.html"> |
| |
| |
| 7 注册中心参考手册 |
| |
| </a> |
| |
| |
| |
| <ul class="articles"> |
| |
| |
| <li class="chapter " data-level="1.8.1" data-path="reference-registry/multicast.html"> |
| |
| <a href="reference-registry/multicast.html"> |
| |
| |
| 7.1 Multicast注册中心 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.8.2" data-path="reference-registry/zookeeper.html"> |
| |
| <a href="reference-registry/zookeeper.html"> |
| |
| |
| 7.2 Zookeeper注册中心 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.8.3" data-path="reference-registry/redis.html"> |
| |
| <a href="reference-registry/redis.html"> |
| |
| |
| 7.3 Redis注册中心 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.8.4" data-path="reference-registry/simple.html"> |
| |
| <a href="reference-registry/simple.html"> |
| |
| |
| 7.4 Simple注册中心 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| |
| </ul> |
| |
| </li> |
| |
| <li class="chapter " data-level="1.9" data-path="reference-telnet/telnet.html"> |
| |
| <a href="reference-telnet/telnet.html"> |
| |
| |
| 8 telnet命令参考手册 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.10" data-path="reference-maven/maven.html"> |
| |
| <a href="reference-maven/maven.html"> |
| |
| |
| 9 maven插件参考手册 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.11" data-path="best-practice.html"> |
| |
| <a href="best-practice.html"> |
| |
| |
| 10 服务化最佳实践 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter active" data-level="1.12" data-path="recommend.html"> |
| |
| <a href="recommend.html"> |
| |
| |
| 11 推荐用法 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.13" data-path="capacity-plan.html"> |
| |
| <a href="capacity-plan.html"> |
| |
| |
| 12 容量规划 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.14" data-path="benchmark.html"> |
| |
| <a href="benchmark.html"> |
| |
| |
| 13 基准测试工具包 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.15" data-path="perf-test.html"> |
| |
| <a href="perf-test.html"> |
| |
| |
| 14 性能测试报告 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1.16" data-path="coveragence.html"> |
| |
| <a href="coveragence.html"> |
| |
| |
| 15 测试覆盖率报告 |
| |
| </a> |
| |
| |
| |
| </li> |
| |
| |
| |
| |
| <li class="divider"></li> |
| |
| <li> |
| <a href="https://www.gitbook.com" target="blank" class="gitbook-link"> |
| Published with GitBook |
| </a> |
| </li> |
| </ul> |
| |
| |
| </nav> |
| |
| |
| </div> |
| |
| <div class="book-body"> |
| |
| <div class="body-inner"> |
| |
| |
| |
| <div class="book-header" role="navigation"> |
| |
| |
| <!-- Title --> |
| <h1> |
| <i class="fa fa-circle-o-notch fa-spin"></i> |
| <a href="." >11 推荐用法</a> |
| </h1> |
| </div> |
| |
| |
| |
| |
| <div class="page-wrapper" tabindex="-1" role="main"> |
| <div class="page-inner"> |
| |
| <div id="book-search-results"> |
| <div class="search-noresults"> |
| |
| <section class="normal markdown-section"> |
| |
| <h4 id="在provider上尽量多配置consumer端属性">在Provider上尽量多配置Consumer端属性</h4> |
| <p>原因如下:</p> |
| <ul> |
| <li>作服务的提供者,比服务使用方更清楚服务性能参数,如调用的超时时间,合理的重试次数,等等</li> |
| <li>在Provider配置后,Consumer不配置则会使用Provider的配置值,即Provider配置可以作为Consumer的缺省值。否则,Consumer会使用Consumer端的全局设置,这对于Provider不可控的,并且往往是不合理的。</li> |
| </ul> |
| <p>PS: 配置的覆盖规则:1) 方法级配置别优于接口级别,即小Scope优先 2) Consumer端配置 优于 Provider 配置 优于全局配置,最后是Dubbo Hard Code的配置值(见<a href="user-guide-configuration-ref#配置参考手册">Dubbo配置参考手册</a>)</p> |
| <p>Provider上尽量多配置Consumer端的属性,让Provider实现者一开始就思考Provider服务特点、服务质量的问题。</p> |
| <p>示例:</p> |
| <pre><code class="lang-xml"><span class="hljs-tag"><<span class="hljs-name">dubbo:service</span> <span class="hljs-attr">interface</span>=<span class="hljs-string">"com.alibaba.hello.api.HelloService"</span> <span class="hljs-attr">version</span>=<span class="hljs-string">"1.0.0"</span> <span class="hljs-attr">ref</span>=<span class="hljs-string">"helloService"</span> |
| <span class="hljs-attr">timeout</span>=<span class="hljs-string">"300"</span> <span class="hljs-attr">retry</span>=<span class="hljs-string">"2"</span> <span class="hljs-attr">loadbalance</span>=<span class="hljs-string">"random"</span> <span class="hljs-attr">actives</span>=<span class="hljs-string">"0"</span> |
| /></span> |
| |
| <span class="hljs-tag"><<span class="hljs-name">dubbo:service</span> <span class="hljs-attr">interface</span>=<span class="hljs-string">"com.alibaba.hello.api.WorldService"</span> <span class="hljs-attr">version</span>=<span class="hljs-string">"1.0.0"</span> <span class="hljs-attr">ref</span>=<span class="hljs-string">"helloService"</span> |
| <span class="hljs-attr">timeout</span>=<span class="hljs-string">"300"</span> <span class="hljs-attr">retry</span>=<span class="hljs-string">"2"</span> <span class="hljs-attr">loadbalance</span>=<span class="hljs-string">"random"</span> <span class="hljs-attr">actives</span>=<span class="hljs-string">"0"</span> ></span> |
| <span class="hljs-tag"><<span class="hljs-name">dubbo:method</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"findAllPerson"</span> <span class="hljs-attr">timeout</span>=<span class="hljs-string">"10000"</span> <span class="hljs-attr">retries</span>=<span class="hljs-string">"9"</span> <span class="hljs-attr">loadbalance</span>=<span class="hljs-string">"leastactive"</span> <span class="hljs-attr">actives</span>=<span class="hljs-string">"5"</span> /></span> |
| <span class="hljs-tag"><<span class="hljs-name">dubbo:service</span>/></span> |
| </code></pre> |
| <p>在Provider可以配置的Consumer端属性有:</p> |
| <ol> |
| <li><code>timeout</code> 方法调用超时</li> |
| <li><code>retries</code> 失败重试次数,缺省是2(表示加上第一次调用,会调用3次)</li> |
| <li><code>loadbalance</code> 负载均衡算法(有多个Provider时,如何挑选Provider调用),缺省是随机(random)。还可以有轮询(roundrobin)、最不活跃优先(leastactive,指从Consumer端并发调用最好的Provider,可以减少的反应慢的Provider的调用,因为反应更容易累积并发的调用)</li> |
| <li><code>actives</code> 消费者端,最大并发调用限制,即当Consumer对一个服务的并发调用到上限后,新调用会Wait直到超时。 |
| 在方法上配置(dubbo:method )则并发限制针对方法,在接口上配置(dubbo:service),则并发限制针对服务。</li> |
| </ol> |
| <p>详细配置说明参见:<a href="reference-xmlconf/dubbo-provider.html">Dubbo配置参考手册</a></p> |
| <h4 id="provider上配置合理的provider端属性">Provider上配置合理的Provider端属性</h4> |
| <pre><code class="lang-xml"><span class="hljs-tag"><<span class="hljs-name">dubbo:protocol</span> <span class="hljs-attr">threads</span>=<span class="hljs-string">"200"</span> /></span> |
| |
| <span class="hljs-tag"><<span class="hljs-name">dubbo:service</span> <span class="hljs-attr">interface</span>=<span class="hljs-string">"com.alibaba.hello.api.HelloService"</span> <span class="hljs-attr">version</span>=<span class="hljs-string">"1.0.0"</span> <span class="hljs-attr">ref</span>=<span class="hljs-string">"helloService"</span> |
| <span class="hljs-attr">executes</span>=<span class="hljs-string">"200"</span> ></span> |
| <span class="hljs-tag"><<span class="hljs-name">dubbo:method</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"findAllPerson"</span> <span class="hljs-attr">executes</span>=<span class="hljs-string">"50"</span> /></span> |
| <span class="hljs-tag"></<span class="hljs-name">dubbo:service</span>></span> |
| </code></pre> |
| <p>Provider上可以配置的Provider端属性有:</p> |
| <ol> |
| <li><code>threads</code> 服务线程池大小</li> |
| <li><code>executes</code> 一个服务提供者并行执行请求上限,即当Provider对一个服务的并发调用到上限后,新调用会Wait(Consumer可能到超时)。在方法上配置(dubbo:method )则并发限制针对方法,在接口上配置(dubbo:service),则并发限制针对服务。</li> |
| </ol> |
| <h4 id="配置上管理信息">配置上管理信息</h4> |
| <p>目前有负责人信息和组织信息(用于区分站点)。有问题时便于的找到服务的负责人,至少写两个人以便备份。负责人和组织的信息可以在注册中心的上看到。</p> |
| <p>示例:</p> |
| <p><strong>应用配置负责人、组织</strong></p> |
| <pre><code class="lang-xml"><span class="hljs-tag"><<span class="hljs-name">dubbo:application</span> <span class="hljs-attr">owner</span>=<span class="hljs-string">”ding.lid,william.liangf”</span> <span class="hljs-attr">organization</span>=<span class="hljs-string">”intl”</span> /></span> |
| </code></pre> |
| <p><strong>service配置负责人</strong></p> |
| <pre><code class="lang-xml"><span class="hljs-tag"><<span class="hljs-name">dubbo:service</span> <span class="hljs-attr">owner</span>=<span class="hljs-string">”ding.lid,william.liangf”</span> /></span> |
| </code></pre> |
| <p><strong>reference配置负责人</strong></p> |
| <pre><code class="lang-xml"><span class="hljs-tag"><<span class="hljs-name">dubbo:reference</span> <span class="hljs-attr">owner</span>=<span class="hljs-string">”ding.lid,william.liangf”</span> /></span> |
| </code></pre> |
| <p>dubbo:service、dubbo:reference没有配置负责人,则使用dubbo:application设置的负责人。</p> |
| <h4 id="配置上dubbo缓存文件">配置上Dubbo缓存文件</h4> |
| <p>配置方法如下:</p> |
| <p><strong>提供者列表缓存文件</strong></p> |
| <pre><code class="lang-xml"><span class="hljs-tag"><<span class="hljs-name">dubbo:registry</span> <span class="hljs-attr">file</span>=<span class="hljs-string">”${user.home}</span>/<span class="hljs-attr">output</span>/<span class="hljs-attr">dubbo.cache</span>” /></span> |
| </code></pre> |
| <p>注意:</p> |
| <ol> |
| <li>文件的路径,应用可以根据需要调整,保证这个文件不会在发布过程中被清除。</li> |
| <li>如果有多个应用进程注意不要使用同一个文件,避免内容被覆盖。</li> |
| </ol> |
| <p>这个文件会缓存:</p> |
| <ol> |
| <li>注册中心的列表</li> |
| <li>服务提供者列表</li> |
| </ol> |
| <p>有了这项配置后,当应用重启过程中,Dubbo注册中心不可用时则应用会从这个缓存文件读取服务提供者列表的信息,进一步保证应用可靠性。</p> |
| <h4 id="监控配置">监控配置</h4> |
| <ol> |
| <li><p>使用固定端口暴露服务,而不要使用随机端口</p> |
| <p> 这样在注册中心推送有延迟的情况下,消费者通过缓存列表也能调用到原地址,保证调用成功。</p> |
| </li> |
| <li><p>使用Dragoon的http监控项监控注册中心上服务提供方</p> |
| <p> Dragoon监控服务在注册中心上的状态:<a href="http://dubbo-reg1.hst.xyi.cn.alidc.net:8080/status/com.alibaba.morgan.member.MemberService:1.0.5" target="_blank">http://dubbo-reg1.hst.xyi.cn.alidc.net:8080/status/com.alibaba.morgan.member.MemberService:1.0.5</a> 确保注册中心上有该服务的存在。</p> |
| </li> |
| <li><p>服务提供方,使用Dragoon的telnet或shell监控项</p> |
| <p> 监控服务提供者端口状态:<code>echo status | nc -i 1 20880 | grep OK | wc -l</code>,其中的20880为服务端口</p> |
| </li> |
| <li><p>服务消费方,通过将服务强制转型为EchoService,并调用$echo()测试该服务的提供者是可用</p> |
| <p> 如 <code>assertEqauls(“OK”, ((EchoService)memberService).$echo(“OK”));</code></p> |
| </li> |
| </ol> |
| <h4 id="不要使用dubboproperties文件配置,推荐使用对应xml配置">不要使用dubbo.properties文件配置,推荐使用对应XML配置</h4> |
| <p>Dubbo2中所有的配置项都可以Spring配置中,并且可以针对单个服务配置。</p> |
| <p>如完全不配置使用Dubbo缺省值,参见 <a href="reference-xmlconf/introduction.html">Dubbo配置参考手册</a> 中的说明。</p> |
| <p>在Dubbo1中需要在dubbo.properties文件中的配置项,Dubbo2中配置示例如下:</p> |
| <ol> |
| <li><p>应用名 </p> |
| <pre><code class="lang-xml"> <span class="hljs-tag"><<span class="hljs-name">dubbo:application</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"myalibaba"</span> ></span> |
| </code></pre> |
| <p> 对应dubbo.properties中的Key名<code>dubbo.application.name</code></p> |
| </li> |
| <li><p>注册中心地址</p> |
| <pre><code class="lang-xml"> <span class="hljs-tag"><<span class="hljs-name">dubbo:registry</span> <span class="hljs-attr">address</span>=<span class="hljs-string">"11.22.33.44:9090"</span> ></span> |
| </code></pre> |
| <p> 对应dubbo.properties中的Key名<code>dubbo.registry.address</code></p> |
| </li> |
| <li><p>调用超时</p> |
| <p> 可以在多个配置项设置超时,由上至下覆盖(即上面的优先),示例如下:</p> |
| <p> 其它的参数(retries、loadbalance、actives等)的覆盖策略也一样。</p> |
| <p> <strong>提供者端特定方法的配置</strong></p> |
| <pre><code class="lang-xml"> <span class="hljs-tag"><<span class="hljs-name">dubbo:service</span> <span class="hljs-attr">interface</span>=<span class="hljs-string">"com.alibaba.xxx.XxxService"</span> ></span> |
| <span class="hljs-tag"><<span class="hljs-name">dubbo:method</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"findPerson"</span> <span class="hljs-attr">timeout</span>=<span class="hljs-string">"1000"</span> /></span> |
| <span class="hljs-tag"></<span class="hljs-name">dubbo:service</span>></span> |
| </code></pre> |
| <p> <strong>提供者端特定接口的配置</strong></p> |
| <pre><code class="lang-xml"> <span class="hljs-tag"><<span class="hljs-name">dubbo:service</span> <span class="hljs-attr">interface</span>=<span class="hljs-string">"com.alibaba.xxx.XxxService"</span> <span class="hljs-attr">timeout</span>=<span class="hljs-string">"200"</span> /></span> |
| </code></pre> |
| <p> timeout可以在多处设置,配置项及覆盖规则详见: <a href="reference-xmlconf/introduction.html">Dubbo配置参考手册</a></p> |
| <p> 全局配置项值,对应dubbo.properties中的Key名<code>dubbo.service.invoke.timeout</code></p> |
| </li> |
| <li><p>服务提供者协议、服务的监听端口</p> |
| <pre><code class="lang-xml"><span class="hljs-tag"><<span class="hljs-name">dubbo:protocol</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"dubbo"</span> <span class="hljs-attr">port</span>=<span class="hljs-string">"20880"</span> /></span> |
| </code></pre> |
| <p> 对应dubbo.properties中的Key名<code>dubbo.service.protocol、dubbo.service.server.port</code></p> |
| </li> |
| <li><p>服务线程池大小</p> |
| <pre><code class="lang-xml"> <span class="hljs-tag"><<span class="hljs-name">dubbo:protocol</span> <span class="hljs-attr">threads</span>=<span class="hljs-string">"100"</span> /></span> |
| </code></pre> |
| <p> 对应 dubbo.properties 中的Key名<code>dubbo.service.max.thread.threads.size</code></p> |
| </li> |
| <li><p>消费者启动时,没有提供者是否抛异常Fast-Fail</p> |
| <pre><code class="lang-xml"> <span class="hljs-tag"><<span class="hljs-name">dubbo:reference</span> <span class="hljs-attr">interface</span>=<span class="hljs-string">"com.alibaba.xxx.XxxService"</span> <span class="hljs-attr">check</span>=<span class="hljs-string">"false"</span> /></span> |
| </code></pre> |
| <p> 对应 dubbo.properties 中的Key名<code>alibaba.intl.commons.dubbo.service.allow.no.provider</code></p> |
| </li> |
| </ol> |
| |
| |
| </section> |
| |
| </div> |
| <div class="search-results"> |
| <div class="has-results"> |
| |
| <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1> |
| <ul class="search-results-list"></ul> |
| |
| </div> |
| <div class="no-results"> |
| |
| <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1> |
| |
| </div> |
| </div> |
| </div> |
| |
| </div> |
| </div> |
| |
| </div> |
| |
| |
| |
| <a href="best-practice.html" class="navigation navigation-prev " aria-label="Previous page: 10 服务化最佳实践"> |
| <i class="fa fa-angle-left"></i> |
| </a> |
| |
| |
| <a href="capacity-plan.html" class="navigation navigation-next " aria-label="Next page: 12 容量规划"> |
| <i class="fa fa-angle-right"></i> |
| </a> |
| |
| |
| |
| </div> |
| |
| <script> |
| var gitbook = gitbook || []; |
| gitbook.push(function() { |
| gitbook.page.hasChanged({"page":{"title":"11 推荐用法","level":"1.12","depth":1,"next":{"title":"12 容量规划","level":"1.13","depth":1,"path":"capacity-plan.md","ref":"capacity-plan.md","articles":[]},"previous":{"title":"10 服务化最佳实践","level":"1.11","depth":1,"path":"best-practice.md","ref":"best-practice.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"recommend.md","mtime":"2017-07-28T03:11:34.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-07-28T06:06:18.782Z"},"basePath":".","book":{"language":""}}); |
| }); |
| </script> |
| </div> |
| |
| |
| <script src="gitbook/gitbook.js"></script> |
| <script src="gitbook/theme.js"></script> |
| |
| |
| <script src="gitbook/gitbook-plugin-search/search-engine.js"></script> |
| |
| |
| |
| <script src="gitbook/gitbook-plugin-search/search.js"></script> |
| |
| |
| |
| <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script> |
| |
| |
| |
| <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script> |
| |
| |
| |
| <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script> |
| |
| |
| |
| <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script> |
| |
| |
| |
| </body> |
| </html> |
| |