首页  

dubbo常用配置     所属分类 dubbo 浏览量 1373
服务提供者
dubbo:service

version 服务版本 通常在接口不兼容时版本号才需要升级
group 服务分组 
delay 延迟注册服务时间(毫秒) ,设为-1 , Spring容器初始化完成时暴露服务
timeout 远程服务调用超时时间(毫秒)


服务消费者 使用服务
dubbo:reference

version 服务版本,与服务提供者的版本一致
group 服务分组 
timeout 服务方法调用超时时间(毫秒)
retries 远程服务调用重试次数,不包括第一次调用, 设为0不重试
check  启动时检查提供者是否存在, 设置为 true 服务提供者不存在报错
url 点对点直连 绕过注册中心


url="dubbo://localhost:20890"





关闭所有服务的启动时检查:(没有提供者时报错)
<dubbo:consumer check="false" />

关闭某个服务的启动时检查:(没有提供者时报错)
<dubbo:reference interface="com.foo.BarService" check="false" />
其它的启动时检查还包括注册中心

异步调用

<dubbo:reference id="helloService" interface="com.dyyx.HelloService">
    <dubbo:method name="sayHello" async="true" />
</dubbo:reference>


dubbo:protocol属性
threadpool:线程池类型, fixed/cached ,默认fixed 
threads :服务线程池大小(固定大小) ,默认为100
payload:请求及响应数据包大小限制,单位:字节,默认为88388608(=8M)

<dubbo:protocol name="dubbo" port="27001" threadpool="cached" threads="20"/>

fixed 固定大小线程池,启动时建立线程,不关闭,一直持有。(缺省)
cached 缓存线程池,空闲一分钟自动删除,需要时重建。
limited 可伸缩线程池,但池中的线程数只会增长不会收缩。(为避免收缩时突然来了大流量引起的性能问题)。

dubbo:application
name 必填 ,应用名称,用于注册中心计算应用间依赖关系,
注意:消费者和提供者应用名不要一样 !!!


Dubbo协议缺省 使用单一长连接,如果数据量大并发量高,可使用多个连接 消费者配置


<dubbo:reference id="helloService" interface="dyyx.HelloService" group="${dubbo.group}" connections="100"/>


<dubbo:protocol name="dubbo" port=“9090” server="netty" client="netty" codec="dubbo" 
serialization="hessian2" charset="UTF-8" threadpool="fixed" threads="100" queues="0" 
iothreads="9" buffer="8192" accepts="1000" payload="8388608" />



设置随机端口
默认 20880
<dubbo:protocol name="dubbo" port="-1" />

20880 被 占用后 会尝试使用  20881 20882 ...


<dubbo:protocol name="dubbo" port="20880" accesslog="true"/>

dubbo:protocol name
dubbo rmi hessian webservice




注册中心配置
dubbo.register=zookeeper://127.0.0.1:2181


config 模块 com.alibaba.dubbo.config.spring.schema.DubboNamespaceHandler registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true)); registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true)); registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true)); registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true)); registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true)); registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true)); registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true)); registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true)); registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false)); registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true)); com.alibaba.dubbo.config.ProviderConfig
dubbo 实例 https://gitee.com/dyyx/hellocode/tree/master/project/dubbo-hello-provider https://gitee.com/dyyx/hellocode/tree/master/project/dubbo-hello-consumer

上一篇     下一篇
grafana使用模板变量

dubbo架构及调用模型

dubbo支持的rpc协议及使用场景

进程网络流量查看

linux网络流量监控工具 iftop ifstat nload

修改linux主机名几种方法