【Rpc】基於開源Dubbo分布式RPC服務框架的部署整合
一、前言
Dubbo 作為SOA服務化治理方案的核心框架,用於提高業務邏輯的復用、整合、集中管理,具有極高的可靠性(HA)和伸縮性,被應用於阿裏巴巴各成員站點,同時在包括JD、當當在內的眾多互聯網項目中有著廣泛應用。dubbo 通過高性能 RPC 實現服務的輸出和輸入功能,框架基於 Spring Framework 進行無縫集成,使用過程中基本看不到 Dubbo API的直接調用,Dubbo服務支持RMI、Hessian、Dubbo、WebService等眾多通信協議,同時提供了對服務的監控和管理平臺,屬於一套完整的SOA解決方案。
詳細介紹請參照官方地址: http://alibaba.github.io/dubbo-doc-static/Home-zh.htm ,不再重復描述,本文主要記錄了詳細的開發整合步驟。 引用一張官方提供的dubbo架構圖:
-
Provider 暴露服務方稱之為“服務提供者”。
-
Consumer 調用遠程服務方稱之為“服務消費者”。
-
Registry 服務註冊與發現的中心目錄服務稱之為“服務註冊中心”。
-
Monitor 統計服務的調用次調和調用時間的日誌服務稱之為“服務監控中心”。
- Container 服務運行“容器”。
二、源碼構建
1、dubbo基於maven構建,需要先配置maven環境,當然如果你不想構建源碼,也可以直接下載對應版本的發行包。
2、dubbo構建需要依賴opensesame組件,先通過 git 獲取並安裝opensesame,源碼地址:
https://github.com/alibaba/opensesame
執行maven安裝:mvn install
3、通過下面 git 地址獲取對應版本的 dubbo 源碼,官方推薦使用 dubbo 2.4.9,本文基於trunk版本構建。
https://github.com/alibaba/dubbo
maven構建:mvn clean install -Dmaven.test.skip,在漫長的等待後(過程需要通過網絡下載依賴資源)會有如下提示,生成的 jar 包位於各自目錄的target文件夾。
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] dubbo-parent ....................................... SUCCESS [ 1.272 s]
[INFO] dubbo-common ....................................... SUCCESS [ 4.572 s]
[INFO] dubbo-container .................................... SUCCESS [ 0.024 s]
[INFO] dubbo-container-api ................................ SUCCESS [ 1.148 s]
[INFO] dubbo-container-spring ............................. SUCCESS [ 0.524 s]
[INFO] dubbo-container-jetty .............................. SUCCESS [ 0.420 s]
[INFO] dubbo-container-log4j .............................. SUCCESS [ 0.448 s]
[INFO] dubbo-container-logback ............................ SUCCESS [ 0.468 s]
[INFO] dubbo-remoting ..................................... SUCCESS [ 0.016 s]
[INFO] dubbo-remoting-api ................................. SUCCESS [ 1.864 s]
[INFO] dubbo-remoting-netty ............................... SUCCESS [ 1.125 s]
[INFO] dubbo-remoting-mina ................................ SUCCESS [ 0.696 s]
[INFO] dubbo-remoting-grizzly ............................. SUCCESS [ 0.680 s]
[INFO] dubbo-remoting-p2p ................................. SUCCESS [ 1.048 s]
[INFO] dubbo-remoting-http ................................ SUCCESS [ 0.616 s]
[INFO] dubbo-remoting-zookeeper ........................... SUCCESS [ 0.716 s]
[INFO] dubbo-rpc .......................................... SUCCESS [ 0.016 s]
[INFO] dubbo-rpc-api ...................................... SUCCESS [ 1.608 s]
[INFO] dubbo-rpc-default .................................. SUCCESS [ 1.396 s]
[INFO] dubbo-rpc-injvm .................................... SUCCESS [ 0.760 s]
[INFO] dubbo-rpc-rmi ...................................... SUCCESS [ 0.416 s]
[INFO] dubbo-rpc-hessian .................................. SUCCESS [ 0.584 s]
[INFO] dubbo-rpc-http ..................................... SUCCESS [ 0.580 s]
[INFO] dubbo-rpc-webservice ............................... SUCCESS [ 0.536 s]
[INFO] dubbo-cluster ...................................... SUCCESS [ 2.208 s]
[INFO] dubbo-registry ..................................... SUCCESS [ 0.020 s]
[INFO] dubbo-registry-api ................................. SUCCESS [ 1.241 s]
[INFO] dubbo-monitor ...................................... SUCCESS [ 0.016 s]
[INFO] dubbo-monitor-api .................................. SUCCESS [ 0.464 s]
[INFO] dubbo-filter ....................................... SUCCESS [ 0.016 s]
[INFO] dubbo-filter-validation ............................ SUCCESS [ 0.608 s]
[INFO] dubbo-filter-cache ................................. SUCCESS [ 0.604 s]
[INFO] dubbo-registry-default ............................. SUCCESS [ 0.540 s]
[INFO] dubbo-monitor-default .............................. SUCCESS [ 0.588 s]
[INFO] dubbo-registry-multicast ........................... SUCCESS [ 0.632 s]
[INFO] dubbo-config ....................................... SUCCESS [ 0.016 s]
[INFO] dubbo-config-api ................................... SUCCESS [ 1.500 s]
[INFO] dubbo-config-spring ................................ SUCCESS [ 1.520 s]
[INFO] dubbo-rpc-thrift ................................... SUCCESS