dubbo是分佈式管理框架,主要用於管理分佈式系統.zookeeper是分佈式協調的治理工具。
dubbo是什麼?
- 一款分佈式服務框架
- 高性能和透明化的RPC遠程服務調用方案
- SOA服務治理方案
dubbo架構圖

Provider:服務提供方
Consumer:服務消費者
Registry:註冊中心
Monitor:統計服務調用次數和調用時間的監控中心
調用流程:
0 . 啟動服務
1. 服務提供者啟動的時候, 向註冊中心提供自己的服務
2.服務消費者啟動的時候,向註冊中心訂閱自己的服務
3.註冊中心將服務提供者地址列表返回給服務消費者,如果有變更,註冊中心將基於長變更變更數據返回給消費者
4.服務消費者,基於軟負載均衡算法,選一臺提供者進行調用,如果調用失敗,再選擇另外一臺服務提供者進行調用.
5.服務消費者和服務提供者, 在內容中累計調用次數和調用時間, 定時每分鐘發送一次統計數據到監控臺中心.
zookeeper註冊中心
上述途中所或的Register就是註冊中心,dubbo官方推薦的註冊中心是zookeeper
服務提供方: 在註冊中心發佈服務
服務消費方: 在註冊中心訂閱服務
dubbo+zookeeper+SSM框架的配合使用
1.創建maven工程

dubbo : dubbo父類工程, 主要是用來管理所有的jar版本
dubbo-api : dubbo工程所有的接口
dubbo-consumer : dubbo 消費者
dubbo-provider : dubbo提供者 , 所有公共接口的實現
dubbo-consumer-user : dubbo 消費用戶
2. 創建服務方
2.1 服務方接口
- package com.provider;
- public interface DemoService {
- String sayHello(String name);
- }
2.2服務方接口實現類
- package com.provider;
- import org.springframework.stereotype.Service;
- @Service(value="demoService")
- public class DemoServiceImpl implements DemoService{
- public String sayHello(String name) {
- return "Hello Dubbo,Hello " + name;
- }
- }
2.3 applicationContext.xml
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:jdbc="http://www.springframework.org/schema/jdbc"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"
- >
2.4 dubbo-provider.xml
- 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">
閱讀更多 菜根譚 的文章