關(guān)于我們
書單推薦
新書推薦
|
RocketMQ消息中間件實(shí)戰(zhàn)派(上下冊) 讀者對象:對RocketMQ有了解、使用的經(jīng)驗(yàn)后,想要深入源碼而無從下手的人員。 希望學(xué)習(xí)消息隊(duì)列和分布式系統(tǒng)的開發(fā)人員。 企業(yè)消息中間件維護(hù)和支持人員。 RocketMQ代碼貢獻(xiàn)者。
本書覆蓋了開發(fā)人員在落地分布式架構(gòu)過程中使用RocketMQ 的主要技術(shù)點(diǎn),包括RocketMQ 的 高性能通信渠道、生產(chǎn)消息、消費(fèi)消息、存儲(chǔ)消息、分布式事務(wù)消息、消息的可追蹤性、消息的穩(wěn)定性、消息的高并發(fā)、消息的高可用、消息的高性能和RocketMQ 5.x 的新特性。采用"是什么→怎么用→什么原理(源碼分析)”的主線來講解這些技術(shù)點(diǎn)。 本書的主要目標(biāo):①讓讀者在動(dòng)手中學(xué)習(xí),而不是"看書時(shí)好像全明白了,一動(dòng)手卻發(fā)現(xiàn)什么都不會(huì)”;②讓讀者掌握整個(gè)RocketMQ 生態(tài)的全棧技術(shù)和最佳實(shí)踐,而不是只有RocketMQ 框架;③讓讀者從RocketMQ 體系化的視角熟悉RocketMQ 的核心原理,而不是零散且碎片化;④讓讀者成為消息中間件領(lǐng)域的技術(shù)專家或架構(gòu)師,而不只是熟悉RocketMQ;⑤讓讀者具備自研消息中間件的能力,而不是僅停留在源碼分析的層次,"授人以魚,不如授人以漁”是本書最大的宗旨。 本書適合對分布式架構(gòu)及支撐分布式架構(gòu)落地的中間件感興趣的技術(shù)開發(fā)人員。無論讀者是否接觸過 分布式消息中間件,只要具備一定的Java 開發(fā)基礎(chǔ),都能通過本書的學(xué)習(xí)快速掌握分布式架構(gòu)中消息中間件的開發(fā)技能,并利用RocketMQ 消息中間件支撐分布式架構(gòu)的落地。
曾就職于網(wǎng)易考拉、微醫(yī)集團(tuán)、連連支付、政采云等杭州一線獨(dú)角獸公司,高級技術(shù)專家(P8)和業(yè)務(wù)負(fù)責(zé)人,具備跨境電商、跨境支付等業(yè)務(wù)領(lǐng)域0-1的架構(gòu)設(shè)計(jì)和開發(fā)落地能力,擅長高并發(fā)、高可用、和高性能系統(tǒng)架構(gòu)設(shè)計(jì)。
第1 篇 基礎(chǔ)
第1 章 初識(shí)RocketMQ ·························.2 1.1 認(rèn)識(shí)分布式架構(gòu) ····························.2 1.1.1 什么是分布式 ·······················.2 1.1.2 什么是架構(gòu) ··························.3 1.1.3 分布式架構(gòu)的冰與火 ··············.5 1.2 認(rèn)識(shí)RocketMQ ·····························.7 1.2.1 什么是RocketMQ ··················.7 1.2.2 RocketMQ 與分布式架構(gòu) ·······.12 1.3 搭建RocketMQ 環(huán)境 ····················.13 1.3.1 了解RocketMQ 相關(guān)的安裝包 .13 1.3.2 搭建單Master 的單機(jī)環(huán)境 ·····.15 1.3.3 搭建多Master 的集群環(huán)境 ·····.15 1.3.4 搭建單Master 和單Slave 的集群環(huán)境 ·································.16 1.3.5 【實(shí)例】搭建Raft 集群環(huán)境 ··.18 1.4 RocketMQ 5.0 的新特性 ················.20 第2 章 實(shí)現(xiàn)通信渠道 ··························.22 2.1 認(rèn)識(shí)通信渠道 ·····························.22 2.2 通信渠道的架構(gòu) ··························.25 2.2.1 認(rèn)識(shí)Netty ·························.25 2.2.2 RocketMQ 通信渠道的架構(gòu) ····.29 2.3 使用Netty 實(shí)現(xiàn)通信渠道的原理 ······.33 2.3.1 實(shí)現(xiàn)通信渠道的通信協(xié)議 ······.33 2.3.2 實(shí)現(xiàn)客戶端通信渠道 ············.38 2.3.3 實(shí)現(xiàn)服務(wù)端通信渠道 ············.41 2.4 使用客戶端連接服務(wù)端 ·················.47 2.4.1 分析模塊通信渠道的類型 ······.48 2.4.2 連接服務(wù)端 ························.50 2.5 【實(shí)例】修改通信渠道客戶端和服務(wù)端的線程模型 ·······················.54 第3 章 消息路由信息的無狀態(tài)存儲(chǔ)和管理 ······································.61 3.1 了解消息路由信息 ·······················.61 3.2 Name Server 的架構(gòu) ·····················.68 3.2.1 認(rèn)識(shí)無狀態(tài)架構(gòu) ··················.68 3.2.2 認(rèn)識(shí)Name Server 架構(gòu) ·········.69 3.2.3 認(rèn)識(shí)地址服務(wù)架構(gòu) ···············.72 3.2.4 【實(shí)例】用地址服務(wù)動(dòng)態(tài)更新客戶端中的Name Server 節(jié)點(diǎn)的地址信息 ··························.74 3.3 “使用Name Server 存儲(chǔ)和管理消息路由信息”的原理 ·······················.77 3.3.1 Name Server 的啟動(dòng)流程 ·······.77 3.3.2 注冊Broker Server ···············.84 3.3.3 取消注冊的業(yè)務(wù)場景和取消注冊Broker Server ···············.89 3.3.4 存儲(chǔ)和管理消息路由信息 ······.93 3.4 【實(shí)例】啟動(dòng)多個(gè)Name Server 節(jié)點(diǎn),模擬故障以驗(yàn)證Name Server 節(jié)點(diǎn)的無狀態(tài)性 ·································.101 第4 章 生產(chǎn)消息和消費(fèi)消息 ···············.104 4.1 生產(chǎn)和消費(fèi)消息的模式 ················.104 4.1.1 生產(chǎn)消息 ··························.104 4.1.2 消費(fèi)消息 ··························.110 4.2 消費(fèi)消息的類型 ·························.116 4.2.1 集群消息 ··························.116 4.2.2 廣播消息 ··························.118 4.2.3 順序消息 ··························.119 4.2.4 并發(fā)消息 ··························.125 4.2.5 延遲消息 ··························.126 4.2.6 事務(wù)消息 ··························.130 4.3 生產(chǎn)消息 ··································.134 4.3.1 生產(chǎn)者SDK 的3 種使用方式 ································.135 4.3.2 采用“同步”模式生產(chǎn)消息 ···.137 4.3.3 采用“異步”模式生產(chǎn)消息 ···.142 4.3.4 采用“最多發(fā)送一次”模式生產(chǎn)消息 ··························.148 4.4 消費(fèi)消息 ··································.152 4.4.1 采用pull 模式消費(fèi)消息 ········.153 4.4.2 采用push 模式消費(fèi)消息 ·······.171 4.4.3 采用pop 模式消費(fèi)消息 ········.183 4.5 采用“請求/應(yīng)答”消息實(shí)現(xiàn)同步調(diào)用 ········································.197 4.5.1 “請求/應(yīng)答”消息的架構(gòu) ····.197 4.5.2 分析“請求/應(yīng)答”消息的過程 ································.198 4.6 【實(shí)例】生產(chǎn)者發(fā)送消息,消費(fèi)者順序地消費(fèi)消息 ·························.212 4.6.1 驗(yàn)證“普通順序消息” ········.212 4.6.2 驗(yàn)證“嚴(yán)格順序消息” ········.217 第5 章 存儲(chǔ)消息 ······························.219 5.1 認(rèn)識(shí)存儲(chǔ)引擎 ····························.219 5.1.1 什么是存儲(chǔ)引擎 ·················.219 5.1.2 存儲(chǔ)引擎的架構(gòu) ·················.221 5.2 認(rèn)識(shí)存儲(chǔ)模型 ····························.222 5.2.1 消息模型 ··························.222 5.2.2 文件模型 ··························.229 5.2.3 【實(shí)例】利用源碼遠(yuǎn)程調(diào)試存儲(chǔ)模型 ································.236 5.3 啟動(dòng)存儲(chǔ)引擎 ····························.238 5.3.1 初始化Broker Server 和存儲(chǔ)引擎 ································.238 5.3.2 啟動(dòng)Broker Server 和存儲(chǔ)引擎 ································.247 5.3.3 【實(shí)例】動(dòng)態(tài)修改存儲(chǔ)引擎的配置參數(shù) ··························.251 5.4 使用存儲(chǔ)引擎處理“儲(chǔ)存消息”的請求 ········································.253 5.4.1 接收并處理生產(chǎn)消息的請求 ································.254 5.4.2 存儲(chǔ)消息 ··························.257 5.4.3 【實(shí)例】利用存儲(chǔ)引擎實(shí)現(xiàn)批量地存儲(chǔ)消息 ·······················.262 5.5 對比存儲(chǔ)單條消息和批量消息的性能 ········································.263 第6 章 治理消息 ······························.268 6.1 如何治理消息 ····························.268 6.1.1 治理消息的目標(biāo) ·················.268 6.1.2 使用消息度量提供治理消息的依據(jù) ································.276 6.1.3 使用消息管控實(shí)現(xiàn)治理消息的落地 ································.280 6.2 認(rèn)識(shí)命令控制臺(tái)和UI 控制臺(tái) ········.285 6.2.1 什么是命令控制臺(tái)和UI控制臺(tái) ·····························.285 6.2.2 啟動(dòng)命令控制臺(tái)和UI控制臺(tái) ·····························.289 6.2.3 使用對象池管理RocketMQDashboard 中通信渠道客戶端的核心類 ·····························.292 6.3 使用命令控制臺(tái)治理消息 ·············.298 6.3.1 執(zhí)行治理消息的命令 ···········.299 6.3.2 【實(shí)例】使用命令控制臺(tái),完成 RocketMQ 集群的擴(kuò)容 ·········.322 6.3.3 【實(shí)例】使用命令控制臺(tái),完成 RocketMQ 集群的縮容 ·········.325 6.3.4 【實(shí)例】使用命令控制臺(tái),動(dòng)態(tài)增加Topic 的讀/寫消息隊(duì)列的數(shù)量 ·················.332 6.4 使用UI 控制臺(tái)治理消息 ··············.334 6.4.1 使用UI 控制臺(tái)治理消息的原理 ································.335 6.4.2 【實(shí)例】使用UI 控制臺(tái)手動(dòng)地禁用消費(fèi)者組 ····················.341 6.4.3 【實(shí)例】使用UI 控制臺(tái)重置消費(fèi)者進(jìn)度 ·······················.343 第7 章 實(shí)現(xiàn)分布式事務(wù) ·····················.345 7.1 什么是分布式事務(wù) ······················.345 7.1.1 本地事務(wù) ··························.345 7.1.2 分布式事務(wù) ·······················.350 7.1.3 事務(wù)消息與數(shù)據(jù)的最終一致性 ·····························.354 7.2 使用“兩階段提交”模式處理事務(wù)消息 ········································.359 7.3 使用“定時(shí)回調(diào)”機(jī)制查詢本地事務(wù)狀態(tài) ········································.370 7.4 【實(shí)例】架構(gòu)師如何在電商項(xiàng)目中落地分布式事務(wù) ·························.380 7.4.1 分析業(yè)務(wù)場景 ····················.380 7.4.2 分析業(yè)務(wù)復(fù)雜度 ·················.381 7.4.3 分析技術(shù)復(fù)雜度 ·················.385 7.4.4 落地代碼 ··························.391 7.4.5 驗(yàn)證接入的結(jié)果 ·················.392 7.5 【實(shí)例】使用泛娛樂業(yè)務(wù)驗(yàn)證事務(wù)消息的故障轉(zhuǎn)移機(jī)制 ···················.393 7.5.1 準(zhǔn)備環(huán)境 ··························.394 7.5.2 架構(gòu)設(shè)計(jì) ··························.394 7.5.3 代碼設(shè)計(jì) ··························.395 7.5.4 驗(yàn)證故障轉(zhuǎn)移 ····················.397 第8 章 實(shí)現(xiàn)消息的可追蹤性 ···············.402 8.1 消息的可追蹤性 ·························.402 8.1.1 認(rèn)識(shí)消息的可追蹤性 ···········.402 8.1.2 為什么需要消息的可追蹤性 ···.404 8.1.3 RocketMQ 支持的追蹤類型 ···.404 8.2 使用消息軌跡實(shí)現(xiàn)消息的可追蹤性 ··································.405 8.2.1 認(rèn)識(shí)消息軌跡 ····················.405 8.2.2 軌跡樹的原理 ····················.412 8.2.3 【實(shí)例】開啟消息軌跡,追蹤生產(chǎn)消息、消費(fèi)消息和結(jié)束事務(wù)消息的過程 ································.421 8.3 使用Hook 機(jī)制收集Trace 消息 ······.422 8.3.1 什么是Hook 機(jī)制 ···············.422 8.3.2 “使用Hook 機(jī)制的實(shí)現(xiàn)類收集Trace 消息”的原理 ······.425 8.4 使用“定時(shí)線程任務(wù)”異步存儲(chǔ)Trace信息 ········································.428 8.4.1 為什么要異步存儲(chǔ) ··············.428 8.4.2 異步存儲(chǔ)Trace 信息的過程 ···.431 8.4.3 【實(shí)例】斷點(diǎn)調(diào)試“客戶端異步存儲(chǔ)Trace 信息”···············.441 8.5 使用“OpenTracing + Jaeger”實(shí)現(xiàn)消息的分布式鏈路追蹤 ·························.444 8.5.1 認(rèn)識(shí)OpenTracing ···············.444 8.5.2 認(rèn)識(shí)Jaeger ·······················.446 8.5.3 “使用Jaeger 收集消息鏈路數(shù)據(jù)”的原理 ·····························.446 8.5.4 “使用OpenTracing 規(guī)范消息鏈路追蹤”的原理 ····················.448 8.5.5 【實(shí)例】收集普通消息和事務(wù)消息,使用Jaeger 實(shí)現(xiàn)可視化 ········.452 8.6 【實(shí)例】自定義Hook 和Trace 信息的派發(fā)類 ·····································.456 8.6.1 設(shè)計(jì) ································.457 8.6.2 關(guān)鍵代碼分析 ····················.457 第9 章 保證消息的穩(wěn)定性 ··················.461 9.1 什么是消息的穩(wěn)定性 ···················.461 9.1.1 認(rèn)識(shí)穩(wěn)定性 ·······················.461 9.1.2 認(rèn)識(shí)消息的穩(wěn)定性 ··············.466 9.1.3 消息穩(wěn)定性技術(shù) ·················.467 9.2 實(shí)現(xiàn)RocketMQ 的實(shí)時(shí)監(jiān)控 ··········.472 9.2.1 認(rèn)識(shí)RocketMQ Exporter 及其相關(guān)組件 ··························.472 9.2.2 實(shí)時(shí)監(jiān)控的邏輯架構(gòu) ···········.474 9.2.3 “使用RocketMQ Exporter 實(shí)現(xiàn)實(shí)時(shí)監(jiān)控”的原理 ··············.477 9.2.4 搭建監(jiān)控環(huán)境 ····················.486 9.2.5 【實(shí)例】基于Prometheus 和Alert Manager 的RocketMQ實(shí)時(shí)告警 ··························.494 9.3 實(shí)現(xiàn)RocketMQ 客戶端的實(shí)時(shí)度量 ··································.503 9.3.1 認(rèn)識(shí)Skywalking ·················.503 9.3.2 “使用Skywalking 實(shí)時(shí)度量RocketMQ 客戶端”的原理 ···.504 9.3.3 搭建監(jiān)控環(huán)境 ····················.509 9.3.4 【實(shí)例】修改源碼動(dòng)態(tài)設(shè)置一些延遲時(shí)間,觸發(fā)基于Skywalking和釘釘?shù)母婢撝?··············.511 9.4 【實(shí)例】使用RocketMQ Dashboard實(shí)時(shí)監(jiān)控RocketMQ ····················.515 9.4.1 設(shè)計(jì) ································.515 9.4.2 修改RocketMQ Dashboard 的源碼 ································.516 9.4.3 配置監(jiān)控規(guī)則 ····················.517 9.4.4 初始化生產(chǎn)者和消費(fèi)者服務(wù) ··.517 9.4.5 驗(yàn)證監(jiān)控告警 ····················.518 9.5 【實(shí)例】改造RocketMQ 以支持Nacos 集群管理 ··························.520 9.5.1 架構(gòu)設(shè)計(jì) ··························.520 9.5.2 落地代碼 ··························.521 9.5.3 驗(yàn)證 ································.524 第4 篇 高并發(fā)、高可用和高性能 第10 章 消息的高并發(fā) ······················.528 10.1 消息的高并發(fā)概述 ·····················.528 10.1.1 什么是高并發(fā) ··················.528 10.1.2 為什么要實(shí)現(xiàn)消息的高并發(fā) ·····························.529 10.2 使用“管理通信渠道”實(shí)現(xiàn)消息的高并發(fā) ·····································.530 10.2.1 通信渠道與高并發(fā) ············.530 10.2.2 管理生產(chǎn)者與Broker Server之間的通信渠道 ·················.532 10.2.3 管理消費(fèi)者與Broker Server之間的通信渠道 ·················.533 10.3 使用“提高消費(fèi)者處理消息的功能”實(shí)現(xiàn)消息的高并發(fā) ······················.534 10.3.1 消費(fèi)者處理消息的功能與高并發(fā) ·····························.534 10.3.2 使用“擴(kuò)容消費(fèi)者客戶端”來提高消費(fèi)消息的并行性 ········.534 10.3.3 采用pop 模式來提高消費(fèi)消息的速度 ································.535 10.3.4 【實(shí)例】實(shí)現(xiàn)“單進(jìn)程單消費(fèi)者的并發(fā)和批量消費(fèi)消息” ·····························.536 10.3.5 【實(shí)例】實(shí)現(xiàn)“單進(jìn)程多消費(fèi)者實(shí)例并發(fā)生產(chǎn)和消費(fèi)消息” ·····························.541 10.4 使用線程池實(shí)現(xiàn)消息的高并發(fā) ······.550 10.4.1 為什么要使用線程池 ·········.550 10.4.2 使用線程池實(shí)現(xiàn)消息的高并發(fā)的原理 ································.551 10.4.3 【實(shí)例】使用RocketMQ 自帶的線程實(shí)現(xiàn)生產(chǎn)和消費(fèi)消息的并發(fā)性 ·····························.558 10.4.4 【實(shí)例】動(dòng)態(tài)修改Consumer客戶端的核心線程數(shù) ···········.559 10.5 采用“異步”模式實(shí)現(xiàn)消息的高并發(fā) ····································.562 10.5.1 使用“回調(diào)+異步響應(yīng)對象”實(shí)現(xiàn)生產(chǎn)者的“異步”模式 ································.562 10.5.2 使用“異步命令事件處理器”實(shí)現(xiàn)Broker Server 的“異步”模式 ································.563 10.5.3 使用“流水線”技術(shù)實(shí)現(xiàn)存儲(chǔ)引擎的“異步”模式 ···········.564 10.6 使用“負(fù)載均衡”實(shí)現(xiàn)消息的高并發(fā) ·····································.566 10.6.1 什么是負(fù)載均衡 ···············.566 10.6.2 “使用選擇器實(shí)現(xiàn)生產(chǎn)消息的負(fù)載均衡”的原理 ··············.576 10.6.3 “使用客戶端負(fù)載均衡實(shí)現(xiàn)消費(fèi)消息的均衡性”的原理 ········.577 10.6.4 “使用服務(wù)端負(fù)載均衡實(shí)現(xiàn)消費(fèi)消息的均衡性”的原理 ········.578 10.6.5 【實(shí)例】動(dòng)態(tài)調(diào)整消費(fèi)者客戶端的負(fù)載均衡策略 ·················.579 第11 章 消息的高可用 ·······················.583 11.1 什么是消息的高可用 ··················.583 11.1.1 生產(chǎn)消息的高可用 ············.584 11.1.2 存儲(chǔ)消息的高可用 ············.585 11.1.3 消費(fèi)消息的高可用 ············.585 11.2 實(shí)現(xiàn)生產(chǎn)消息的高可用——利用故障容錯(cuò)機(jī)制 ··································.587 11.2.1 什么是故障容錯(cuò)機(jī)制 ·········.587 11.2.2 重試生產(chǎn)消息失敗的請求 ···.588 11.2.3 過濾故障的Broker Server ····.590 11.2.4 故障延遲 ························.591 11.2.5 【實(shí)例】在Spring Cloud Alibaba項(xiàng)目中,植入故障并驗(yàn)證故障 容錯(cuò)機(jī)制 ··························.594 11.3 實(shí)現(xiàn)消費(fèi)消息的高可用——利用重試隊(duì)列和死信隊(duì)列 ·························.596 11.3.1 利用“重試隊(duì)列”實(shí)現(xiàn)高可用的核心原理 ··························.597 11.3.2 利用“死信隊(duì)列”實(shí)現(xiàn)高可用的核心原理 ··························.598 11.3.3 【實(shí)例】動(dòng)態(tài)調(diào)整重試策略,并驗(yàn)證消費(fèi)失敗的高可用性 ···.599 11.3.4 【實(shí)例】在消息重試失敗后,消費(fèi)死信隊(duì)列中的消息 ········.601 11.4 實(shí)現(xiàn)Broker Server 的高可用——利用主/從同步 ·································.602 11.4.1 什么是主/從同步 ···············.602 11.4.2 實(shí)現(xiàn)主/從節(jié)點(diǎn)之間的通信渠道 ································.605 11.4.3 實(shí)現(xiàn)主/從節(jié)點(diǎn)之間消息的同步 ································.610 11.4.4 【實(shí)例】模擬Broker Server主/從同步的業(yè)務(wù)場景 ··········.614 11.5 實(shí)現(xiàn)Broker Server 的高可用——利用多副本架構(gòu)(Dledger) ···············.617 11.5.1 什么是多副本架構(gòu)(DLedger) ·······················.617 11.5.2 “多副本架構(gòu)的通信渠道”的原理 ································.618 11.5.3 “多副本架構(gòu)的協(xié)議”的原理 ································.621 11.5.4 “多副本架構(gòu)的手動(dòng)選舉”的原理 ································.627 11.5.5 “多副本架構(gòu)的自動(dòng)選舉”的原理 ································.631 11.5.6 “多副本架構(gòu)的消息存儲(chǔ)”的原理 ································.634 11.5.7 “多副本架構(gòu)中集群之間消息同步”的原理 ····················.638 11.5.8 【實(shí)例】在主節(jié)點(diǎn)出現(xiàn)故障后,多副本架構(gòu)(DLedger)自動(dòng)選舉,并保持主/從消息一致性 ·······.645 11.6 【實(shí)例】模擬業(yè)務(wù)場景“從主/從架構(gòu)升級為多副本架構(gòu)”,并驗(yàn)證消息的高可用性 ··································.651 11.7 【實(shí)例】使用微服務(wù)來驗(yàn)證多副本的手動(dòng)選舉功能的高可用性 ·············.654 第12 章 消息的高性能 ······················.657 12.1 什么是消息的高性能 ·················.657 12.1.1 生產(chǎn)消息的高性能 ············.657 12.1.2 存儲(chǔ)消息的高性能 ············.659 12.1.3 消費(fèi)消息的高性能 ············.660 12.2 使用本地緩存實(shí)現(xiàn)高性能 ···········.661 12.2.1 緩存客戶端通信渠道 ·········.661 12.2.2 緩存消息路由信息 ············.663 12.2.3 【實(shí)例】使用IDEA 調(diào)試“緩存客戶端通信渠道” ······.665 12.3 提升存儲(chǔ)消息的性能——利用CommitLog 文件順序?qū)?···············.670 12.3.1 什么是CommitLog 文件 ·····.670 12.3.2 CommitLog 文件的存儲(chǔ)格式 ································.672 12.3.3 利用“順序?qū)憽贝鎯?chǔ)消息的原理 ································.673 12.4 提高消費(fèi)消息的速度——利用ConsumeQueue 文件實(shí)現(xiàn) ··············.676 12.4.1 什么是ConsumeQueue文件 ································.677 12.4.2 構(gòu)建ConsumeQueue 文件 ····.678 12.4.3 利用ConsumeQueue 文件提高消費(fèi)消息的性能 ·················.683 12.5 提高查詢消息的速度——利用索引文件實(shí)現(xiàn) ··································.684 12.5.1 什么是索引文件 ···············.684 12.5.2 構(gòu)建索引文件 ··················.685 12.5.3 利用索引文件提高查詢消息的性能 ································.687 12.6 提升消費(fèi)消息RPC 請求的性能——利用零拷貝實(shí)現(xiàn) ·························.687 12.6.1 什么是零拷貝 ··················.688 12.6.2 使用Netty 的FileRegion 類實(shí)現(xiàn)文件的零拷貝 ····················.688 12.6.3 在Broker Server 的消息處理器中使用零拷貝 ·······················.691 12.7 提升Broker Server 寫消息的性能——利用內(nèi)存映射、Page Cache 及堆外 內(nèi)存實(shí)現(xiàn) ··································.692 12.7.1 什么是內(nèi)存映射、Page Cache 和堆外內(nèi)存 ··························.693 12.7.2 寫消息高性能的邏輯架構(gòu) ···.695 12.7.3 “利用MappedFile 文件實(shí)現(xiàn)內(nèi)存映射”的原理 ··············.696 12.7.4 “利用內(nèi)存映射實(shí)現(xiàn)Page Cache”的原理 ·····························.696 12.7.5 “管理堆外內(nèi)存和Page Cache”的原理 ·····························.697 12.8 清理過期的ConsumeQueue 文件和CommitLog 文件 ························.702 12.8.1 清理過期的ConsumeQueue文件 ································.702 12.8.2 清理過期的CommitLog文件 ································.704 12.8.3 【實(shí)例】利用Spring CloudAlibaba 項(xiàng)目演示清理過期的ConsumeQueue 文件和CommitLog文件 ································.709 第5 篇 應(yīng)用 第13 章 RocketMQ 在分布式架構(gòu)中的應(yīng)用 ····································.712 13.1 RocketMQ 在Spring Boot 中的應(yīng)用 ········································.712 13.1.1 為什么RocketMQ 要支持Spring Boot ·······················.712 13.1.2 利用Spring Boot 作為基礎(chǔ)框架生產(chǎn)和消費(fèi)消息 ·················.713 13.2 RocketMQ 在Spring Cloud Alibaba 中的應(yīng)用 ·······································.719 13.2.1 為什么Spring Cloud Alibaba 要支持RocketMQ ··················.719 13.2.2 利用Spring Cloud Alibaba 作為基礎(chǔ)框架生產(chǎn)和消費(fèi)消息 ·····.719 13.2.3 Spring Cloud Alibaba 定制化RocketMQ 的原理 ···············.728 13.3 【實(shí)例】將命令式編程模式升級為函數(shù)式編程模式,完成消息的生產(chǎn)和消費(fèi) ········································.730 13.3.1 采用命令式編程模式生產(chǎn)和消費(fèi)消息 ··························.730 13.3.2 將命令式編程模式升級為函數(shù)式編程模式 ·················.731 13.4 RocketMQ 在RocketMQ Connect 中的應(yīng)用 ········································.732 13.4.1 什么是Message Connect ·····.733 13.4.2 什么是RocketMQ Connect ··.735 13.4.3 RocketMQ Connect 的核心架構(gòu) ································.736 13.4.4 “利用生產(chǎn)者和消費(fèi)者來同步集群信息”的原理 ··············.739 13.4.5 “利用監(jiān)聽器完成服務(wù)發(fā)現(xiàn)”的原理 ································.743 13.4.6 “利用客戶端負(fù)載均衡實(shí)現(xiàn)同步消息的高吞吐量”的原理 ·····.744 13.4.7 【實(shí)例】搭建RocketMQ Connect的本地和分布式環(huán)境 ···········.747 13.5 RocketMQ 在Event Bridge 中的應(yīng)用 ········································.750 13.5.1 什么是Event Bridge ···········.750 13.5.2 Event Bridge 的核心架構(gòu) ·····.751 13.5.3 利用RocketMQ 實(shí)現(xiàn)EventBridge 的核心原理 ··············.756 13.6 RocketMQ 在多語言環(huán)境中的應(yīng)用 ········································.757 13.6.1 RocketMQ 的多語言架構(gòu)設(shè)計(jì) ································.757 13.6.2 【實(shí)例】使用Go 語言客戶端生產(chǎn)和消費(fèi)消息 ·················.758 13.7 RocketMQ 在大數(shù)據(jù)中的應(yīng)用 ······.760 13.7.1 RocketMQ Streams 的核心架構(gòu) ································.761 13.7.2 【實(shí)例】利用RocketMQ Streams處理微服務(wù)中的流數(shù)據(jù) ········.765 第6 篇 新特性 章 分析RocketMQ 5.x 的新特性 ··.768 14.1 利用“對等部署模式”實(shí)現(xiàn)BrokerServer 的高可用 ·························.768 14.1.1 認(rèn)識(shí)“對等部署模式” ······.768 14.1.2 實(shí)現(xiàn)“對等部署模式”的原理 ································.771 14.1.3 【實(shí)例】利用微服務(wù)來驗(yàn)證“對等部署模式”的高可用 ···.777 14.2 利用“Slave 代理Master 模式”實(shí)現(xiàn)Broker Server 的高可用 ················.778 14.2.1 認(rèn)識(shí)“Slave 代理Master模式” ·····························.778 14.2.2 實(shí)現(xiàn)“Slave 代理Master模式”的原理 ····················.779 14.2.3 【實(shí)例】利用微服務(wù)來驗(yàn)證“Slave 代理Master 模式”的 高可用 ·····························.788 14.3 利用“RocketMQ Controller 模式”實(shí)現(xiàn)Broker Server 的高可用 ·········.790 14.3.1 認(rèn)識(shí)“RocketMQ Controller模式” ·····························.791 14.3.2 實(shí)現(xiàn)“RocketMQ Controller模式”的原理 ····················.793 14.3.3 利用“RocketMQ Controller模式”完成集群管理 ···········.797 14.3.4 實(shí)現(xiàn)“RocketMQ Controller 模式中多副本狀態(tài)機(jī)”的原理 ·····.806 14.3.5 【實(shí)例】驗(yàn)證“RocketMQController 模式”的 高可用性 ··························.810 14.4 利用“RocketMQ Proxy 模式”統(tǒng)一多語言客戶端 ····························.814 14.4.1 認(rèn)識(shí)“RocketMQ Proxy模式” ·····························.814 14.4.2 實(shí)現(xiàn)“RocketMQ Proxy 模式”的原理 ································.816 14.4.3 實(shí)現(xiàn)“代理多語言客戶端請求”的原理 ···························.821
你還可能感興趣
我要評論
|