Dubbo学习之旅一-初识Dubbo

1.Dubbo是什么

Dubbo是一个分布式服务框架, 是SOA面向服务的架构的一种很好的实现,致力于提高性能和透明化的RPC(Remote Procedure Call Protocol)远程服务调用方案, dubbo就是一个服务框架,如果没有分布式的需求,其实是不需要用的

核心内容包括:

  • 远程通讯 : 提供对多种基于长连接的NIO框架抽象封装,包括多种线程模型,序列化,以及“请求-响应”模式的信息交换方式

  • 集群容错:  提供基于接口方法的透明远程过程调用,包括多协议支持,以及软负载均衡,失败容错,地址路由,动态配置等集群支持

  • 自动发现: 基于注册中心目录服务,使服务消费方能动态的查找服务提供方,使地址透明,使服务提供方可以平滑增加或减少机器

2.Dubbo能做什么

  1. 透明化的远程方法调用, 就像本地方法一样调用远程方法,只需要简单配置,没有任何API侵入

  2. 软负载均衡及容错机制

  3. 服务自动注册与发现, 不再需要写死服务提供方地址

Dubbo采用全spring配置方式,透明化接入应用,对应用没有任何API侵入,只需要spring加载dubbo的配置即可


3.Dubbo的架构


节点角色说明:

       Provider: 服务提供方

       Consumer: 调用远程服务的服务消费方

       Registry: 服务注册与发现的注册中心

       Monitor: 统计服务的调用次调和调用时间的监控中心

       Container: 服务运行容器


调用关系说明:

0.服务容器负责启动,加载,运行服务提供者

1. 服务提供者在启动时,向注册中心注册自己提供的服务

2. 服务消费者在启动时,向注册中心订阅自己所需的服务

3. 注册中心返回服务提供者地址列表给消费者,如果有变更,注册中心将基于长连接推送变更数据给消费者

4. 服务消费者,从提供者地址列表中,基于软负载均衡算法,选一台提供者进行调用,如果调用失败,再选另一台调用

5. 服务消费者和提供者,在内存中累计调用次数和调用时间,定时每分钟发送一次统计数据到监控中心


4.Dubbo的使用

关于dubbo的使用 我们首先需要启动zookeeeper服务, 关于zookeeper的启动和安装可以参照我的blog: http://my.oschina.net/chenxiaobian/blog/667093

首先一定要保证zookeeper能够正常启动

下面介绍一下dubbo的管理页面

这里需要将dubbo-admin.war部署到tomcat中

  1. git clone https://github.com/alibaba/dubbo/tree/master/dubbo-admin

  2. mvn clean install -Dmaven.test.skip 打包成dubbo-admin.war

  3. 将dubbo-admin.war放入tomcat/webapp目录下 解压成dubbo目录

  4. 运行tomcat 保证启动没有错误

  5. 运行成功后, 在浏览器栏输入http://localhost:8080/dubbo可以看到下面的页面:

至此dubbo的管理页面就运行成功了

这里需要注意一点

在运行tomcat的时候可能会出现以下错误:

ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'uriBrokerService': Cannot create inner bean '(inner bean)' of type [com.alibaba.citrus.service.uribroker.impl.URIBrokerServiceImpl$URIBrokerInfo] while setting bean property 'brokers' with key [0]; nested excepti
on is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#25': Cannot create inner bean 'server' of type [com.alibaba.citrus.service.uribroker.uri.GenericURIBroker] while setting constructor argument; nested exception is org.springframework.beans.fact
ory.BeanCreationException: Error creating bean with name 'server': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'URIType' of bean class [com.alibaba.citrus.service.uribroker.uri.GenericURIBroker]: Bean property 'URIType'
is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:230)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:287)

错误的原因是因为你的jdk可能是1.8的 与项目编译的兼容问题, 常见的解决方案是把自己的jdk改成1.7的 或者改一下依赖

详细的内容请参考: https://github.com/alibaba/dubbo/issues/50

下一篇我将会重点介绍dubbo如何在项目中使用,以实战为主来介绍

转载于:https://my.oschina.net/chenxiaobian/blog/667129

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值