Dubbo[]是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案。
其核心部分包含:
- 远程通讯: 提供对多种基于长连接的NIO框架抽象封装,包括多种线程模型,序列化,以及“请求-响应”模式的信息交换方式。
- 集群容错: 提供基于接口方法的透明远程过程调用,包括多协议支持,以及软负载均衡,失败容错,地址路由,动态配置等集群支持。
- 自动发现: 基于注册中心目录服务,使服务消费方能动态的查找服务提供方,使地址透明,使服务提供方可以平滑增加或减少机器。
Dubbo能做什么?
- 透明化的远程方法调用,就像调用本地方法一样调用远程方法,只需简单配置,没有任何API侵入。
- 软负载均衡及容错机制,可在内网替代F5等硬件负载均衡器,降低成本,减少单点。
- 服务自动注册与发现,不再需要写死服务提供方地址,注册中心基于接口名查询服务提供者的IP地址,并且能够平滑添加或删除服务提供者。
Spring配置本地bean时
<bean id=“xxxService” class=“com.xxx.XxxServiceImpl” /> <bean id=“xxxAction” class=“com.xxx.XxxAction”> <property name=“xxxService” ref=“xxxService” /> </bean>
远程服务配置时,需要增加在提供方增加暴露服务配置<dubbo:service>,在消费方增加引用服务配置<dubbo:reference>
服务方配置
<!-- 和本地服务一样实现远程服务 --> <bean id=“xxxService” class=“com.xxx.XxxServiceImpl” /> <!-- 增加暴露远程服务配置 --> <dubbo:service interface=“com.xxx.XxxService” ref=“xxxService” />
消费方配置
<!-- 增加引用远程服务配置 --> <dubbo:reference id=“xxxService” interface=“com.xxx.XxxService” /> <!-- 和本地服务一样使用远程服务 --> <bean id=“xxxAction” class=“com.xxx.XxxAction”> <property name=“xxxService” ref=“xxxService” /> </bean>
来个栗子,接口
public interface DemoService { String sayHello(String name); }
实现
public class DemoServiceImpl implements DemoService { public String sayHello(String name) { return "Hello " + name; } }
服务方配置
<!-- 声明需要暴露的服务接口 --> <dubbo:service interface="com.alibaba.dubbo.demo.DemoService" ref="demoService" /> <!-- 和本地bean一样实现服务 --> <bean id="demoService" class="com.alibaba.dubbo.demo.provider.DemoServiceImpl" />
消费方配置
<!-- 生成远程服务代理,可以和本地bean一样使用demoService --> <dubbo:reference id="demoService" interface="com.alibaba.dubbo.demo.DemoService" />
bubbo用户指南
http://dubbo.io/User+Guide-zh.htm
相关推荐
Dubbo+Maven消费方和服务费, Dubbo+Maven消费方和服务费
这是一个学习zookeeper+dubbo+spring的代码例子,一个maven工程
项目有maven搭建,整合dubbo+spring+springMvc+mybatis+Mysql,压缩包有两个项目分别是提供者和消费者两个项目,启动方式是打成WAR,在tomcat启动
mavan+dubbo+spring+zookeeper简单demo实践,解决初学者一些问题
zookpeer+dubbo+spring tomcat启动和 本地两个测试demo以及需要的所有工具和jar
使用mybatis+spring+springMVC+maven+dubbo搭建的一个消费者与提供者的项目
Springboot+Redis+Dubbo+Rocketmq Springboot+Redis+Dubbo+Rocketmq Springboot+Redis+Dubbo+Rocketmq
微服务架构面试题系列:Dubbo+Spring Boot+Spring Cloud+Nginx+ActiveMQ+RabbitMQ+Kafka
dubbo服务层(含所需jar包) 步骤: 1、配置本项目的applicationConsumer.xml的zookeeper路径 2、运行Main即可访问服务层的实现类 服务端请移步到:http://download.csdn.net/detail/tiantang_1986/9716561 注意...
借鉴官网的一个Demo,Dubbo+Zookeeper+Spring整合,一个简单的Demo源码
微服务架构面试专题系列:Dubbo+Spring Boot+Spring Cloud.zip
zk+dubbo+spring本地工程
dubbo+zookeeper+SpringMVC+Spring+Mybatis+Freemarker集成
代码开发工具:IDEA,操作系统:windows 7 64位,代码功能:对spring+springMVC+dubbo+mybatis的整合实现用户信息的增删查改,修改对于初学者可以有帮助。
压缩包内包含搭建简单的Dubbo+Zookeeper+Spring项目所需的全部jar包,在自己写的项目中拿出来的,保证可以使用。
ZooKeeper+dubbo+springMvc+Mybatis+Mysql实例,项目是由maven搭建的 整合Dubbo\spring\springMvc\Mybatis,整个压缩包中有两个项目分别是提供者和消费,启动方式是打成WAR形式放到tomcat中启动。
运用SpringBoot+Dubbo+Zookeeper实现的分布式微服务,分服务端与客户端。
面试专题-面试人员必看-微服务架构面试专题系列:Dubbo+Spring Boot+Spring Cloud
dubbo+zookeeper+spring -demo 分布式系统 demo