dubbo基础(一)dubbo概念及特点

一 dubbo是什么

Dubbo底层是使用NIO的RPC做远程调度

Dubbo 是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案。

核心部分包含:

远程通讯: 提供对多种基于长连接的NIO求-响应”模式的信息交换方式。

集群容错: 提供基于接口方法的透明远程容错,地址路由,动态配置等集群支持.

自动发现: 基于注册中心目录服务,使服服务提供方可以平滑增加或减少机


二 dubbo能做什么
透明化的远程方法调用,就像调用本地方法一样调用远程方法,只需简单配置,没有任何API侵
入。
软负载均衡及容错机制,可在内网替代F5等硬件负载均衡器,降低成本,减少单点。
服务自动注册与发现,不再需要写死服务提供方地址,注册中心基于接口名查询服务提供者的IP
地址,并且能够平滑添加或删除服务提供者

三 dubbo多版本的配置

服务提供方

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans        
    http://www.springframework.org/schema/beans/spring-beans.xsd        
    http://code.alibabatech.com/schema/dubbo        
    http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
 
  <!-- 指定web服务名字 -->
    <dubbo:application name="Dubbo_HelloWorld"/>
    <!-- 声明服务注册中心 -->
    <dubbo:registry  protocol="zookeeper" address="192.168.1.122:2181"/>
    <!-- 指定传输层通信协议 -->
    <dubbo:protocol name="dubbo" port="20880"/>
    <dubbo:protocol name="rmi" port="1099"/>
    
    <!-- 暴露你的服务地址 -->
    <dubbo:service 
    ref="demoService1" 
    interface="com.baizhi.service.IDemoService"
    protocol="dubbo,rmi"
    version="1.1.0"
    />
     <dubbo:service 
    ref="demoService2" 
    interface="com.baizhi.service.IDemoService"
    protocol="dubbo,rmi"
    version="1.1.1"
    />

 </beans>

服务消费方

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans        
    http://www.springframework.org/schema/beans/spring-beans.xsd        
    http://code.alibabatech.com/schema/dubbo        
    http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
 
  <!-- 指定web服务名字 -->
    <dubbo:application name="Dubbo_HelloWorld"/>
    <!-- 声明服务注册中心 -->
    <dubbo:registry protocol="zookeeper" address="192.168.1.122:2181"/>
    
    <!-- 指定传输层通信协议 -->
    <dubbo:protocol name="dubbo" port="20881"/>
    <dubbo:protocol name="rmi" port="1010"/>
    
    <!-- 暴露你的服务地址 -->
    <dubbo:reference 
    id="demoService1" 
    interface="com.baizhi.service.IDemoService"
    protocol="dubbo"
    version="1.1.0"
    />
     <dubbo:reference 
    id="demoService2" 
    interface="com.baizhi.service.IDemoService"
    protocol="dubbo"
    version="1.1.1"
    />
    <dubbo:reference 
    id="demoService3" 
    interface="com.baizhi.service.IDemoService"
    protocol="dubbo"
    version="*"
    />
 </beans>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值