Dubbo Schema Configuration
The official document: http://dubbo.apache.org/zh-cn/docs/user/references/xml/introduction.html
dubbo:servic
Table from http://dubbo.apache.org/zh-cn/docs/user/references/xml/dubbo-service.html
Attributes | The corresponding URL parameter | Types of | Required | The default value | effect | description | compatibility |
---|---|---|---|---|---|---|---|
interface | class | Mandatory | Service Discovery | Service interface name | 1.0.0 or later | ||
ref | object | Mandatory | Service Discovery | Service object implements reference | 1.0.0 or later | ||
version | version | string | Optional | 0.0.0 | Service Discovery | Service version, it is recommended to use a two-digit version, such as: 1.0, generally only need to upgrade the version number when it is not compatible interfaces | 1.0.0 or later |
group | group | string | Optional | Service Discovery | Packet service, when a plurality of interfaces implemented, a packet can be used to distinguish | 1.0.7 or later | |
path |
|
string | Optional | The default name for the interface | Service Discovery | Services path (Note: 1.0 does not support custom path, always use the interface name, if there is 1.0 tone 2.0, configure the service path may not be compatible) | 1.0.12 or later |
delay | delay | int | Optional | 0 | Performance Tuning | Registration service delay time (ms), set to -1 represents the delay to the exposed service initialization completion Spring container | 1.0.14 or later |
timeout | timeout | int | Optional | 1000 | Performance Tuning | Remote service call timeout (ms) | 2.0.0 or later |
retries | retries | int | Optional | 2 | Performance Tuning | Remote service call retries, not including the first call, no retries Set to 0 | 2.0.0 or later |
connections | connections | int | Optional | 100 | Performance Tuning | The maximum number of connections for each provider, rmi, http, hessian and other short connection protocol meant to be limiting the number of connections, dubbo as long as the number is connected Association said long connection establishment | 2.0.0 or later |
loadbalance | loadbalance | string | Optional | random | Performance Tuning | Load balancing strategy, optional value: random, roundrobin, leastactive, respectively: a randomized, robin, least active call | 2.0.0 or later |
async | async | boolean | Optional | false | Performance Tuning | Whether the default asynchronous execution, unreliable asynchronous, just ignore the return value, do not block execution thread | 2.0.0 or later |
local | local | class/boolean | Optional | false | Service Management | 设为true,表示使用缺省代理类名,即:接口名 + Local后缀,已废弃,请使用stub | 2.0.0以上版本 |
stub | stub | class/boolean | 可选 | false | 服务治理 | 设为true,表示使用缺省代理类名,即:接口名 + Stub后缀,服务接口客户端本地代理类名,用于在客户端执行本地逻辑,如本地缓存等,该本地代理类的构造函数必须允许传入远程代理对象,构造函数如:public XxxServiceStub(XxxService xxxService) | 2.0.0以上版本 |
mock | mock | class/boolean | 可选 | false | 服务治理 | 设为true,表示使用缺省Mock类名,即:接口名 + Mock后缀,服务接口调用失败Mock实现类,该Mock类必须有一个无参构造函数,与Local的区别在于,Local总是被执行,而Mock只在出现非业务异常(比如超时,网络异常等)时执行,Local在远程调用之前执行,Mock在远程调用后执行。 | 2.0.0以上版本 |
token | token | string/boolean | 可选 | false | 服务治理 | 令牌验证,为空表示不开启,如果为true,表示随机生成动态令牌,否则使用静态令牌,令牌的作用是防止消费者绕过注册中心直接访问,保证注册中心的授权功能有效,如果使用点对点调用,需关闭令牌功能 | 2.0.0以上版本 |
registry | string | 可选 | 缺省向所有registry注册 | 配置关联 | 向指定注册中心注册,在多个注册中心时使用,值为dubbo:registry的id属性,多个注册中心ID用逗号分隔,如果不想将该服务注册到任何registry,可将值设为N/A | 2.0.0以上版本 | |
provider | string | 可选 | 缺省使用第一个provider配置 | 配置关联 | 指定provider,值为dubbo:provider的id属性 | 2.0.0以上版本 | |
deprecated | deprecated | boolean | 可选 | false | 服务治理 | 服务是否过时,如果设为true,消费方引用时将打印服务过时警告error日志 | 2.0.5以上版本 |
dynamic | dynamic | boolean | 可选 | true | 服务治理 | 服务是否动态注册,如果设为false,注册后将显示后disable状态,需人工启用,并且服务提供者停止时,也不会自动取消册,需人工禁用。 | 2.0.5以上版本 |
accesslog | accesslog | string/boolean | 可选 | false | 服务治理 | 设为true,将向logger中输出访问日志,也可填写访问日志文件路径,直接把访问日志输出到指定文件 | 2.0.5以上版本 |
owner | owner | string | 可选 | 服务治理 | 服务负责人,用于服务治理,请填写负责人公司邮箱前缀 | 2.0.5以上版本 | |
document | document | string | 可选 | 服务治理 | 服务文档URL | 2.0.5以上版本 | |
weight | weight | int | 可选 | 性能调优 | 服务权重 | 2.0.5以上版本 | |
executes | executes | int | 可选 | 0 | 性能调优 | 服务提供者每服务每方法最大可并行执行请求数 | 2.0.5以上版本 |
proxy | proxy | string | 可选 | javassist | 性能调优 | 生成动态代理方式,可选:jdk/javassist | 2.0.5以上版本 |
cluster | cluster | string | 可选 | failover | 性能调优 | 集群方式,可选:failover/failfast/failsafe/failback/forking | 2.0.5以上版本 |
filter | service.filter | string | 可选 | default | 性能调优 | 服务提供方远程调用过程拦截器名称,多个名称用逗号分隔 | 2.0.5以上版本 |
listener | exporter.listener | string | 可选 | default | 性能调优 | 服务提供方导出服务监听器名称,多个名称用逗号分隔 | |
protocol | string | 可选 | 配置关联 | 使用指定的协议暴露服务,在多协议时使用,值为dubbo:protocol的id属性,多个协议ID用逗号分隔 | 2.0.5以上版本 | ||
layer | layer | string | 可选 | 服务治理 | 服务提供者所在的分层。如:biz、dao、intl:web、china:acton。 | 2.0.7以上版本 | |
register | register | boolean | 可选 | true | 服务治理 | 该协议的服务是否注册到注册中心 | 2.0.8以上版本 |
xml
配置
<dubbo:application name="user-service-provider"></dubbo:application>
<dubbo:registry protocol="zookeeper" address="127.0.0.1:2181"></dubbo:registry>
<dubbo:protocol name="dubbo" port="20882"></dubbo:protocol>
<dubbo:service interface="com.tcrush.service.UserService"
ref="userServiceImpl" timeout="5000" version="1.0.0">
<dubbo:method name="geAlltUserAddress" timeout="1000"></dubbo:method>
</dubbo:service>
<dubbo:monitor protocol="registry"></dubbo:monitor>
- 属性配置
dubbo.application.name=user-service-provider
dubbo.registry.address=127.0.0.1:2181
dubbo.registry.protocol=zookeeper
dubbo.protocol.name=dubbo
dubbo.protocol.port=20882
dubbo.monitor.protocol=registry
dubbo.scan.base-packages=com.tcrush
。。。。。。
dubbo:consumer
属性 | 对应URL参数 | 类型 | 是否必填 | 缺省值 | 作用 | 描述 | 兼容性 |
---|---|---|---|---|---|---|---|
timeout | default.timeout | int | 可选 | 1000 | 性能调优 | 远程服务调用 超时时间(毫秒) | 1.0.16以上版本 |
retries | default.retries | int | 可选 | 2 | 性能调优 | 远程服务调用 重试次数,不 包括第一次调 用,不需要重 试请设为0,仅 在cluster为 failback/ failover时有效 | 1.0.16以上版本 |
loadbalance | default.loadbalance | string | 可选 | random | 性能调优 | 负载均衡策略, 可选值:random, roundrobin, leastactive, 分别表示: 随机,轮询, 最少活跃调用 | 1.0.16以上版本 |
async | default.async | boolean | 可选 | false | 性能调优 | 是否缺省异步执行, 不可靠异步, 只是忽略返回值, 不阻塞执行线程 | 2.0.0以上版本 |
connections | default.connections | int | 可选 | 100 | 性能调优 | 每个服务对每个 提供者的最大连 接数,rmi、http、 hessian等短连接 协议支持此配置, dubbo协议长连接 不支持此配置 | 1.0.16以上版本 |
generic | generic | boolean | 可选 | false | 服务治理 | 是否缺省泛化接口, 如果为泛化接口, 将返回GenericService | 2.0.0以上版本 |
check | check | boolean | 可选 | true | 服务治理 | 启动时检查提供 者是否存在, true报错,false忽略 | 1.0.16以上版本 |
proxy | proxy | string | 可选 | javassist | 性能调优 | 生成动态代理 方式,可选: jdk/javassist | 2.0.5以上版本 |
owner | owner | string | 可选 | 服务治理 | 调用服务负责人, 用于服务治理, 请填写负责人公司 邮箱前缀 | 2.0.5以上版本 | |
actives | default.actives | int | 可选 | 0 | 性能调优 | 每服务消费者每服务 每方法最大并发调用数 | 2.0.5以上版本 |
cluster | default.cluster | string | 可选 | failover | 性能调优 | 集群方式,可选: failover/failfast/ failsafe/failback/ forking | 2.0.5以上版本 |
filter | reference.filter | string | 可选 | 性能调优 | 服务消费方远程 调用过程拦截器 名称,多个名称 用逗号分隔 | 2.0.5以上版本 | |
listener | invoker.listener | string | 可选 | 性能调优 | 服务消费方引用 服务监听器名称, 多个名称用逗号分隔 | 2.0.5以上版本 | |
registry | string | 可选 | 缺省向所有registry注册 | 配置关联 | 向指定注册中心注册,在 多个注册中心时使用,值为 dubbo:registry的id属性, 多个注册中心ID用逗号分隔, 如果不想将该服务注册到 任何registry, 可将值设为N/A | 2.0.5以上版本 | |
layer | layer | string | 可选 | 服务治理 | 服务调用者所在的分层。 如:biz、dao、 intl:web、china:acton。 | 2.0.7以上版本 | |
init | init | boolean | 可选 | false | 性能调优 | 是否在 afterPropertiesSet() 时饥饿初始化引用, 否则等到有人注入 或引用该实例时再初始化。 | 2.0.10以上版本 |
cache | cache | String /boolean | 可选 | 服务治理 | 以调用参数为key, 缓存返回结果, 可选:lru, threadlocal, jcache等 | Dubbo2.1.0及其以上版本支持 | |
validation | validation | boolean | 可选 | 服务治理 | 是否启用JSR303 标准注解验证, 如果启用,将对方法 参数上的注解进行校验 |
持续更新中...