{"id":10021155,"date":"2025-12-30T17:00:01","date_gmt":"2025-12-30T09:00:01","guid":{"rendered":"https:\/\/itmax.cn\/?p=10021155"},"modified":"2025-12-30T17:00:01","modified_gmt":"2025-12-30T09:00:01","slug":"rocketmq%e9%ab%98%e6%80%a7%e8%83%bd%e6%8f%ad%e7%a7%98%ef%bc%9a%e6%89%bf%e8%bd%bd%e4%b8%87%e4%ba%bf%e7%ba%a7%e6%b5%81%e9%87%8f%e7%9a%84%e6%9e%b6%e6%9e%84%e5%a5%a5%e7%a7%98%ef%bd%9c%e5%be%97%e7%89%a9","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10021155","title":{"rendered":"RocketMQ\u9ad8\u6027\u80fd\u63ed\u79d8\uff1a\u627f\u8f7d\u4e07\u4ebf\u7ea7\u6d41\u91cf\u7684\u67b6\u6784\u5965\u79d8\uff5c\u5f97\u7269\u6280\u672f"},"content":{"rendered":"<h2>\u4e00\u3001\u524d\u8a00<\/h2>\n<p>\u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u67b6\u6784\u4e2d\uff0c\u6d88\u606f\u961f\u5217\u5982\u540c\u7545\u901a\u7684\u201c\u4fe1\u606f\u795e\u7ecf\u7f51\u7edc\u201d\uff0c\u627f\u62c5\u7740\u89e3\u8026\u3001\u524a\u5cf0\u4e0e\u5f02\u6b65\u901a\u4fe1\u7684\u6838\u5fc3\u4f7f\u547d\u3002\u5728\u4f17\u591a\u6210\u719f\u65b9\u6848\u4e2d\uff0cRocketMQ\u51ed\u501f\u5176\u963f\u91cc\u5df4\u5df4\u4e0eApache\u53cc\u91cd\u57fa\u56e0\uff0c\u4ee5\u5353\u8d8a\u7684\u91d1\u878d\u7ea7\u53ef\u9760\u6027\u3001\u4e07\u4ebf\u7ea7\u6d88\u606f\u5806\u79ef\u80fd\u529b\u548c\u7075\u6d3b\u7684\u5206\u5e03\u5f0f\u7279\u6027\u8131\u9896\u800c\u51fa\uff0c\u6210\u4e3a\u6784\u5efa\u9ad8\u53ef\u7528\u3001\u9ad8\u6027\u80fd\u6570\u636e\u6d41\u8f6c\u67a2\u7ebd\u7684\u5173\u952e\u6280\u672f\u9009\u578b\u3002\u672c\u6587\u5c06\u6df1\u5165\u89e3\u6790RocketMQ\u7684\u6838\u5fc3\u67b6\u6784\u3001\u8bbe\u8ba1\u54f2\u5b66\u4e0e\u5b9e\u8df5\u8981\u4e49\u3002<\/p>\n<h2>\u4e8c\u3001RocketMQ\u67b6\u6784\u603b\u89c8<\/h2>\n<p>\u5b98\u7f51\u56fe\u7247<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"351\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdnwdK\" alt=\"\" title=\"\"><\/p>\n<p>RocketMQ\u67b6\u6784\u4e0a\u4e3b\u8981\u5206\u4e3a\u56db\u90e8\u5206\uff0c\u5982\u4e0a\u56fe\u6240\u793a:\u00a0<\/p>\n<p>RocketMQ\u4f5c\u4e3a\u4e00\u6b3e\u9ad8\u6027\u80fd\u3001\u9ad8\u53ef\u7528\u7684\u5206\u5e03\u5f0f\u6d88\u606f\u4e2d\u95f4\u4ef6\uff0c\u5176\u6838\u5fc3\u67b6\u6784\u91c7\u7528\u4e86\u7ecf\u5178\u7684\u56db\u7ec4\u4ef6\u534f\u540c\u8bbe\u8ba1\uff0c\u5b9e\u73b0\u4e86\u6d88\u606f\u751f\u4ea7\u3001\u5b58\u50a8\u3001\u8def\u7531\u4e0e\u6d88\u8d39\u7684\u5168\u94fe\u8def\u89e3\u8026\u4e0e\u9ad8\u6548\u534f\u540c\u3002<strong>\u56db\u5927\u7ec4\u4ef6\u2014\u2014\u751f\u4ea7\u8005\uff08Producer\uff09\u3001\u6d88\u8d39\u8005\uff08Consumer\uff09\u3001\u8def\u7531\u4e2d\u5fc3\uff08NameServer\uff09\u548c\u4ee3\u7406\u670d\u52a1\u5668\uff08Broker\uff09\u2014\u2014\u5404\u53f8\u5176\u804c\uff0c\u5171\u540c\u6784\u5efa\u4e86\u5176\u575a\u5b9e\u7684\u57fa\u77f3\u3002<\/strong><\/p>\n<p><strong>\u751f\u4ea7\u8005\uff08Producer\uff09<\/strong> \u4f5c\u4e3a\u6d88\u606f\u7684\u6e90\u5934\uff0c\u8d1f\u8d23\u5c06\u4e1a\u52a1\u6d88\u606f\u9ad8\u6548\u3001\u53ef\u9760\u5730\u53d1\u5e03\u5230\u7cfb\u7edf\u4e2d\u3002\u5b83\u652f\u6301\u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\uff0c\u5e76\u901a\u8fc7\u5185\u7f6e\u7684\u667a\u80fd\u8d1f\u8f7d\u5747\u8861\u673a\u5236\uff0c\u81ea\u52a8\u9009\u62e9\u6700\u4f18\u7684Broker\u8282\u70b9\u4e0e\u961f\u5217\u8fdb\u884c\u6295\u9012\u3002<\/p>\n<p><strong>\u6d88\u8d39\u8005\uff08Consumer\uff09<\/strong> \u662f\u6d88\u606f\u7684\u5904\u7406\u7ec8\u7aef\uff0c\u540c\u6837\u4ee5\u96c6\u7fa4\u5316\u65b9\u5f0f\u5de5\u4f5c\uff0c\u652f\u6301\u63a8\u9001\uff08Push\uff09\u548c\u62c9\u53d6\uff08Pull\uff09\u4e24\u79cd\u6d88\u606f\u83b7\u53d6\u6a21\u5f0f\u3002\u5b83\u63d0\u4f9b\u4e86\u96c6\u7fa4\u6d88\u8d39\u4e0e\u5e7f\u64ad\u6d88\u8d39\u4e24\u79cd\u6a21\u5f0f\uff0c\u5e76\u80fd\u52a8\u6001\u7ef4\u62a4\u5176\u8ba2\u9605\u5173\u7cfb\u3002<\/p>\n<p><strong>\u8def\u7531\u4e2d\u5fc3\uff08NameServer\uff09<\/strong> \u662f\u6574\u4e2a\u67b6\u6784\u7684\u201c\u6ce8\u518c\u4e2d\u5fc3\u201d\uff0c\u626e\u6f14\u7740\u8f7b\u91cf\u7ea7\u670d\u52a1\u53d1\u73b0\u7684\u89d2\u8272\u3002\u6240\u6709Broker\u8282\u70b9\u90fd\u4f1a\u5411NameServer\u6ce8\u518c\uff0c\u5e76\u901a\u8fc7\u5b9a\u671f\u5fc3\u8df3\u6c47\u62a5\u5065\u5eb7\u72b6\u6001\u3002\u751f\u4ea7\u8005\u4e0e\u6d88\u8d39\u8005\u5219\u4eceNameServer\u83b7\u53d6\u5b9e\u65f6\u7684\u4e3b\u9898\u8def\u7531\u4e0eBroker\u4fe1\u606f\uff0c\u4ece\u800c\u5b9e\u73b0\u6d88\u606f\u5bfb\u5740\u7684\u5b8c\u5168\u89e3\u8026\u3002<\/p>\n<p><strong>\u4ee3\u7406\u670d\u52a1\u5668\uff08Broker\uff09<\/strong> \u662f\u6d88\u606f\u5b58\u50a8\u4e0e\u6d41\u8f6c\u7684\u6838\u5fc3\uff0c\u8d1f\u8d23\u6d88\u606f\u7684\u6301\u4e45\u5316\u5b58\u50a8\u3001\u6295\u9012\u4e0e\u67e5\u8be2\u3002\u4e3a\u4e86\u4fdd\u969c\u9ad8\u53ef\u7528\u6027\uff0cBroker\u901a\u5e38\u91c7\u7528\u4e3b\u4ece\uff08Master-Slave\uff09\u90e8\u7f72\u67b6\u6784\uff0c\u786e\u4fdd\u6570\u636e\u4e0e\u670d\u52a1\u5728\u6545\u969c\u65f6\u80fd\u65e0\u7f1d\u5207\u6362\u3002\u5176\u5185\u90e8\u96c6\u6210\u4e86\u901a\u4fe1\u5904\u7406\u3001\u5b58\u50a8\u5f15\u64ce\u3001\u7d22\u5f15\u670d\u52a1\u548c\u9ad8\u53ef\u7528\u590d\u5236\u7b49\u6838\u5fc3\u6a21\u5757\u3002<\/p>\n<h2>\u4e09\u3001\u6838\u5fc3\u7ec4\u4ef6\u6df1\u5ea6\u89e3\u6790<\/h2>\n<h3>NameServer\uff1a\u8f7b\u91cf\u7ea7\u670d\u52a1\u53d1\u73b0\u67a2\u7ebd<\/h3>\n<p>NameServer\u662fRocketMQ\u7684<strong>\u8f7b\u91cf\u7ea7\u670d\u52a1\u53d1\u73b0\u4e0e\u8def\u7531\u4e2d\u5fc3\uff0c<\/strong> \u5176\u6838\u5fc3\u76ee\u6807\u662f<strong>\u5b9e\u73b0\u751f\u4ea7\u6d88\u8d39\u4e0eBroker\u670d\u52a1\u7684\u89e3\u8026\u3002<\/strong> \u5b83\u4e0d\u5b58\u50a8\u6d88\u606f\u6570\u636e\uff0c\u4ec5\u7ba1\u7406\u8def\u7531\u5143\u6570\u636e\u3002<\/p>\n<p>\u6838\u5fc3\u662f\u4e00\u5f20\u7684\u8def\u7531\u8868\u00a0HashMap&lt;String\/<em> Topic <\/em>\/, List&lt;QueueData&gt;&gt;\uff0c\u8bb0\u5f55\u4e86\u6bcf\u4e2aTopic\u5bf9\u5e94\u5728\u54ea\u4e9bBroker\u7684\u54ea\u4e9b\u961f\u5217\u4e0a\u3002<\/p>\n<p>\u5ba2\u6237\u7aef\u5185\u7f6e\u4e86\u6545\u969c\u89c4\u907f\u673a\u5236\u3002\u5982\u679c\u4ece\u67d0\u4e2aNameServer\u83b7\u53d6\u8def\u7531\u5931\u8d25\uff0c\u6216\u6839\u636e\u8def\u7531\u4fe1\u606f\u8bbf\u95eeBroker\u5931\u8d25\uff0c\u4f1a\u81ea\u52a8\u91cd\u8bd5\u5176\u4ed6NameServer\u6216Broker\u3002<\/p>\n<p>1.\u00a0<strong>\u6838\u5fc3\u89d2\u8272\u4e0e\u8bbe\u8ba1\u54f2\u5b66\uff1a<\/strong>\u00a0NameServer\u7684\u8bbe\u8ba1\u54f2\u5b66\u662f\u00a0<strong>\u201c\u7b80\u5355\u3001\u65e0\u72b6\u6001\u3001\u6700\u7ec8\u4e00\u81f4\u201d \u3002<\/strong> \u6bcf\u4e2aNameServer\u8282\u70b9\u72ec\u7acb\u8fd0\u884c\uff0c<strong>\u8282\u70b9\u95f4\u4e92\u4e0d\u901a\u4fe1\uff0c<\/strong> \u8fd9\u4f7f\u5176\u5177\u5907\u6781\u5f3a\u7684\u6c34\u5e73\u6269\u5c55\u80fd\u529b\u548c\u6781\u9ad8\u7684\u53ef\u7528\u6027\u3002\u5ba2\u6237\u7aef\u4f1a\u914d\u7f6e\u6240\u6709NameServer\u5730\u5740\uff0c\u5e76\u5411\u5176\u5e7f\u64ad\u8bf7\u6c42\u3002<\/p>\n<p>2.\u00a0<strong>\u6838\u5fc3\u5de5\u4f5c\u673a\u5236\uff1a<\/strong> \u5176\u8fd0\u4f5c\u56f4\u7ed5\u8def\u7531\u4fe1\u606f\u7684\u751f\u547d\u5468\u671f\u5c55\u5f00\uff0c\u53ef\u901a\u8fc7\u4e0b\u56fe\u4e00\u89c8\u5176\u6838\u5fc3\u6d41\u7a0b\uff1a<\/p>\n<p><img decoding=\"async\" width=\"543\" height=\"704\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdnwdL\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><strong>3. \u548ckafka\u6ce8\u518c\u4e2d\u5fc3\u5bf9\u6bd4<\/strong><\/p>\n<ul>\n<li><strong>NameServer<\/strong> \u91c7\u7528\u00a0<strong>\u201c\u53bb\u4e2d\u5fc3\u5316\u201d<\/strong>\u00a0\u548c\u00a0<strong>\u201c\u6700\u7ec8\u4e00\u81f4\u201d<\/strong>\u00a0\u601d\u60f3\uff0c<strong>\u8ffd\u6c42\u6781\u81f4\u7684\u7b80\u5355\u3001\u8f7b\u91cf\u548c\u6c34\u5e73\u6269\u5c55\uff0c<\/strong> \u727a\u7272\u4e86\u5f3a\u4e00\u81f4\u6027\uff0c\u4ee5\u6362\u53d6\u67b6\u6784\u7684\u7b80\u6d01\u548c\u9ad8\u53ef\u7528\u3002\u8fd9\u975e\u5e38\u9002\u5408\u8def\u7531\u4fe1\u606f\u53d8\u52a8\u4e0d\u9891\u7e41\u3001\u5ba2\u6237\u7aef\u5177\u5907\u5bb9\u9519\u80fd\u529b\u7684\u6d88\u606f\u573a\u666f\u3002<\/li>\n<li><strong>Kafka (KRaft)<\/strong>\u00a0\u91c7\u7528 <strong>\u201c\u4e2d\u5fc3\u5316\u201d<\/strong> \u548c\u00a0<strong>\u201c\u5f3a\u4e00\u81f4\u201d<\/strong> \u601d\u60f3\uff0c<strong>\u8ffd\u6c42\u6570\u636e\u7684\u7cbe\u786e\u548c\u7cfb\u7edf\u7684\u81ea\u5305\u542b\u3002<\/strong> \u5b83\u5c06\u5143\u6570\u636e\u7ba1\u7406\u6df1\u5ea6\u5185\u5316\uff0c\u901a\u8fc7\u5171\u8bc6\u534f\u8bae\u4fdd\u8bc1\u5168\u5c40\u4e00\u81f4\uff0c\u4f46\u4ee3\u4ef7\u662f\u67b6\u6784\u590d\u6742\u5ea6\u548c\u8fd0\u7ef4\u6210\u672c\u66f4\u9ad8\u3002<\/li>\n<\/ul>\n<p><strong>\u4f18\u52a3\u5206\u6790\uff1a<\/strong> NameServer\u5728<strong>\u8fd0\u7ef4\u7b80\u6613\u6027\u3001\u96c6\u7fa4\u6269\u5c55\u6027\u3001\u65e0\u5916\u90e8\u4f9d\u8d56<\/strong>\u4e0a\u5360\u4f18\uff1b\u800cKafka KRaft\u5728<strong>\u5143\u6570\u636e\u5f3a\u4e00\u81f4\u6027\u3001\u7cfb\u7edf\u81ea\u5305\u542b\u3001\u67b6\u6784\u7edf\u4e00\u6027<\/strong>\u4e0a\u66f4\u80dc\u4e00\u7b79\u3002\u9009\u62e9\u53d6\u51b3\u4e8e\u4f60\u5bf9<strong>\u4e00\u81f4\u6027\u3001\u590d\u6742\u5ea6\u3001\u8fd0\u7ef4\u6210\u672c<\/strong>\u7684\u5177\u4f53\u6743\u8861\u3002<\/p>\n<h3>Broker\uff1a\u6d88\u606f\u5b58\u50a8\u4e0e\u8f6c\u53d1\u7684\u6838\u5fc3\u5f15\u64ce<\/h3>\n<p><strong>\u89e3\u5bc6\u5b58\u50a8\u6587\u4ef6\u8bbe\u8ba1<\/strong><\/p>\n<p>Broker\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u7ed3\u6784<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"137\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdnwdM\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6240\u6709\u6838\u5fc3\u5b58\u50a8\u6587\u4ef6\u5747\u4f4d\u4e8eBroker\u8282\u70b9\u7684\u00a0<strong>${storePathRootDir}\/store\/<\/strong> \u76ee\u5f55\u4e0b\uff08\u9ed8\u8ba4\u8def\u5f84\u4e3a ~\/store\/\uff09\uff0c\u5176\u4e0b\u5404\u5b50\u76ee\u5f55\u804c\u8d23\u5206\u660e\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u76ee\u5f55\/\u6587\u4ef6<\/th>\n<th>\u6838\u5fc3\u804c\u8d23<\/th>\n<th>\u5173\u952e\u8bbe\u8ba1\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>commitlog\/<\/strong><\/td>\n<td><strong>\u6d88\u606f\u5b9e\u4f53\u5b58\u50a8\u5e93<\/strong><\/td>\n<td>\u2022\u00a0<strong>\u8bbe\u8ba1<\/strong>\uff1a\u6240\u6709Topic\u7684\u6d88\u606f<strong>\u987a\u5e8f\u6df7\u5408\u8ffd\u52a0<\/strong>\u5199\u5165\u3002\u2022\u00a0<strong>\u6587\u4ef6<\/strong>\uff1a\u4ee5\u8d77\u59cb\u7269\u7406\u504f\u79fb\u91cf\u547d\u540d\uff0820\u4f4d\u6570\u5b57\uff09\uff0c\u9ed8\u8ba4\u6bcf\u4e2a1GB\u3002<strong>lock\u6587\u4ef6<\/strong>\u786e\u4fdd\u540c\u4e00\u65f6\u523b\u53ea\u6709\u4e00\u4e2a\u8fdb\u7a0b\u5199\u5165\uff0c\u4fdd\u969c\u4e25\u683c\u987a\u5e8f\u5199\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>consumequeue\/<\/strong><\/td>\n<td><strong>\u903b\u8f91\u6d88\u8d39\u961f\u5217\u7d22\u5f15<\/strong><\/td>\n<td>\u2022\u00a0<strong>\u7ed3\u6784<\/strong>\uff1a\u6309\u00a0{Topic}\/{QueueId}\/\u4e09\u7ea7\u76ee\u5f55\u7ec4\u7ec7\u3002\u00a0\u2022\u00a0<strong>\u6587\u4ef6<\/strong>\uff1a\u5b58\u50a8<strong>\u5b9a\u957f\u8bb0\u5f55<\/strong>\uff0820\u5b57\u8282\/\u6761\uff09\uff0c\u5305\u542b\u7269\u7406\u504f\u79fb\u91cf\u3001\u957f\u5ea6\u548cTag\u54c8\u5e0c\u7801\u3002\u00a0\u2022\u00a0<strong>\u4f5c\u7528<\/strong>\uff1a\u4e3a\u6d88\u8d39\u8005\u63d0\u4f9b\u6309Topic\u548c\u961f\u5217\u5206\u7ec4\u7684<strong>\u903b\u8f91\u89c6\u56fe<\/strong>\uff0c\u5b9e\u73b0\u9ad8\u6548\u62c9\u53d6\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>index\/<\/strong><\/td>\n<td><strong>\u6d88\u606f\u952e\u54c8\u5e0c\u7d22\u5f15<\/strong><\/td>\n<td>\u2022\u00a0<strong>\u6587\u4ef6<\/strong>\uff1a\u4ee5\u521b\u5efa\u65f6\u95f4\u6233\u547d\u540d\uff08\u598220240515080000000\uff09\u3002\u00a0\u2022\u00a0<strong>\u7ed3\u6784<\/strong>\uff1a\u91c7\u7528\u00a0<strong>\u201c\u54c8\u5e0c\u69fd + \u94fe\u8868\u201d<\/strong>\u00a0\u7ed3\u6784\u3002\u00a0\u2022\u00a0<strong>\u7528\u9014<\/strong>\uff1a\u652f\u6301\u6839\u636e <strong>Message Key<\/strong>\u00a0\u6216\u65f6\u95f4\u8303\u56f4\u8fdb\u884c\u6d88\u606f\u67e5\u8be2\uff0c\u7528\u4e8e\u8fd0\u7ef4\u6392\u67e5\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>config\/<\/strong><\/td>\n<td><strong>\u8fd0\u884c\u65f6\u5143\u6570\u636e<\/strong><\/td>\n<td>\u2022 \u5b58\u50a8Broker\u8fd0\u884c\u671f\u95f4\u751f\u6210\u7684\u52a8\u6001\u6570\u636e\uff0c\u5982<strong>\u6240\u6709Topic\u7684\u914d\u7f6e<\/strong>\u3001<strong>\u6d88\u8d39\u8005\u7ec4\u7684\u6d88\u8d39\u8fdb\u5ea6\uff08offset\uff09<\/strong>\u00a0\u7b49\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>checkpoint<\/strong><\/td>\n<td><strong>\u72b6\u6001\u68c0\u67e5\u70b9\u6587\u4ef6<\/strong><\/td>\n<td>\u2022 \u8bb0\u5f55\u00a0commitlog\u3001consumequeue\u3001index\u7b49\u6587\u4ef6<strong>\u6700\u540e\u4e00\u6b21\u5237\u76d8\u7684\u65f6\u95f4\u6233<\/strong>\uff0c\u7528\u4e8e\u5d29\u6e83\u6062\u590d\u65f6\u786e\u5b9a\u6570\u636e\u6062\u590d\u7684\u8d77\u70b9\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>abort<\/strong><\/td>\n<td><strong>\u5f02\u5e38\u5173\u95ed\u6807\u5fd7\u6587\u4ef6<\/strong><\/td>\n<td>\u2022 \u8be5\u6587\u4ef6\u5b58\u5728\u5373\u8868\u660eBroker\u4e0a\u4e00\u6b21\u662f<strong>\u975e\u6b63\u5e38\u5173\u95ed<\/strong>\uff0c\u91cd\u542f\u65f6\u4f1a\u89e6\u53d1\u6062\u590d\u6d41\u7a0b\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>lock<\/strong><\/td>\n<td><strong>\u9501\u6587\u4ef6<\/strong><\/td>\n<td>\u2022 lock\u6587\u4ef6\u786e\u4fdd\u540c\u4e00\u65f6\u523b\u53ea\u6709\u4e00\u4e2a\u8fdb\u7a0b\u5199\u5165\uff0c\u4fdd\u969c\u4e25\u683c\u987a\u5e8f\u5199\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>commitLog<\/strong><\/p>\n<p><strong>\u6d88\u606f\u4e3b\u4f53\u4ee5\u53ca\u5143\u6570\u636e\u7684\u5b58\u50a8\u4e3b\u4f53\uff0c<\/strong> \u5b58\u50a8Producer\u7aef\u5199\u5165\u7684\u6d88\u606f\u4e3b\u4f53\u5185\u5bb9\uff0c\u6d88\u606f\u5185\u5bb9<strong>\u4e0d\u662f\u5b9a\u957f\u7684\u3002<\/strong> \u5355\u4e2a\u6587\u4ef6\u5927\u5c0f\u9ed8\u8ba41G\uff0c \u6587\u4ef6\u540d\u957f\u5ea6\u4e3a20\u4f4d\uff0c\u5de6\u8fb9\u8865\u96f6\uff0c\u5269\u4f59\u4e3a<strong>\u8d77\u59cb\u504f\u79fb\u91cf\uff0c<\/strong> \u6bd4\u598200000000000000000000\u4ee3\u8868\u4e86\u7b2c\u4e00\u4e2a\u6587\u4ef6\uff0c\u8d77\u59cb\u504f\u79fb\u91cf\u4e3a0\uff0c\u6587\u4ef6\u5927\u5c0f\u4e3a1G=1073741824\uff1b\u5f53\u7b2c\u4e00\u4e2a\u6587\u4ef6\u5199\u6ee1\u4e86\uff0c\u7b2c\u4e8c\u4e2a\u6587\u4ef6\u4e3a00000000001073741824\uff0c\u8d77\u59cb\u504f\u79fb\u91cf\u4e3a1073741824\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002\u6d88\u606f\u4e3b\u8981\u662f\u987a\u5e8f\u5199\u5165\u65e5\u5fd7\u6587\u4ef6\uff0c\u5f53\u6587\u4ef6\u6ee1\u4e86\uff0c\u5199\u5165\u4e0b\u4e00\u4e2a\u6587\u4ef6\uff1b<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"176\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdnwdN\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5f53\u6211\u4eec\u6d88\u606f\u53d1\u9001\u5230RocketMQ\u4ee5\u540e\uff0c\u6d88\u606f\u5728commitLog\u4e2d\uff0c\u56e0\u4e3abody\u5927\u5c0f\u662f\u4e0d\u56fa\u5b9a\u7684\uff0c\u6240\u4ee5\u6bcf\u4e2a\u6d88\u606f\u7684\u957f\u5ea6\u4e5f\u662f\u4e0d\u56fa\u5b9a\u7684\uff0c\u5176\u5b58\u50a8\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"192\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdnwdO\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e0b\u9762\u6bcf\u4e2a\u8868\u683c\u5217\u4e3e\u4e86\u6bcf\u4e2a\u5b57\u6bb5\u7684\u542b\u4e49<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5b57\u6bb5<\/th>\n<th>\u5b57\u6bb5\u540d<\/th>\n<th>\u6570\u636e\u7c7b\u578b<\/th>\n<th>\u5b57\u8282\u6570<\/th>\n<th>\u8bf4\u660e\u4e0e\u7528\u9014<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td><strong>MsgLen \/ TOTALSIZE<\/strong><\/td>\n<td>int<\/td>\n<td>4<\/td>\n<td><strong>\u6d88\u606f\u603b\u957f\u5ea6<\/strong>\uff0c\u5373\u4ece\u672c\u5b57\u6bb5\u5f00\u59cb\u5230\u7ed3\u675f\u7684\u603b\u5b57\u8282\u6570\uff0c\u662f\u89e3\u6790\u6d88\u606f\u7684\u8d77\u70b9\u3002<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td><strong>MagicCode<\/strong><\/td>\n<td>int<\/td>\n<td>4<\/td>\n<td><strong>\u9b54\u672f\u5b57<\/strong>\uff0c\u56fa\u5b9a\u503c\uff08\u5982\u00a00xdaa320a7\uff09\uff0c\u7528\u4e8e\u6807\u8bc6\u8fd9\u662f\u4e00\u4e2a\u6709\u6548\u7684\u6d88\u606f\u5b58\u50a8\u8d77\u59cb\u70b9\uff0c\u4e5f\u7528\u4e8e\u533a\u5206<strong>\u6d88\u606f\u4f53<\/strong>\u548c<strong>\u6587\u4ef6\u672b\u5c3e\u7a7a\u767d\u586b\u5145\u533a<\/strong>\u3002<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td><strong>BodyCRC<\/strong><\/td>\n<td>int<\/td>\n<td>4<\/td>\n<td><strong>\u6d88\u606f\u4f53\u5185\u5bb9\u7684CRC\u6821\u9a8c\u7801\uff0c<\/strong> \u7528\u4e8e\u6821\u9a8c\u6d88\u606f\u4f53\u5728\u5b58\u50a8\u8fc7\u7a0b\u4e2d\u662f\u5426\u635f\u574f\u3002<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td><strong>QueueId<\/strong><\/td>\n<td>int<\/td>\n<td>4<\/td>\n<td><strong>\u961f\u5217ID<\/strong>\uff0c\u6807\u8bc6\u6b64\u6d88\u606f\u5c5e\u4e8eTopic\u4e0b\u7684\u54ea\u4e2a\u903b\u8f91\u961f\u5217\u3002<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td><strong>Flag<\/strong><\/td>\n<td>int<\/td>\n<td>4<\/td>\n<td><strong>\u6d88\u606f\u6807\u5fd7\u4f4d<\/strong>\uff0c\u4f9b\u5e94\u7528\u7a0b\u5e8f\u81ea\u5b9a\u4e49\u4f7f\u7528\uff0cRocketMQ\u5185\u90e8\u672a\u4f7f\u7528\u3002<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td><strong>QueueOffset<\/strong><\/td>\n<td>long<\/td>\n<td>8<\/td>\n<td><strong>\u6d88\u8d39\u961f\u5217\u504f\u79fb\u91cf<\/strong>\uff0c\u5373\u6b64\u6d88\u606f\u5728\u5176\u5bf9\u5e94ConsumeQueue\u4e2d\u7684\u987a\u5e8f\u7d22\u5f15\uff0c<strong>\u662f\u8fde\u7eed\u7684<\/strong>\u3002<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td><strong>PhysicalOffset<\/strong><\/td>\n<td>long<\/td>\n<td>8<\/td>\n<td><strong>\u7269\u7406\u504f\u79fb\u91cf<\/strong>\uff0c\u5373\u6b64\u6d88\u606f\u5728<strong>\u6240\u6709CommitLog\u6587\u4ef6\u4e2d\u7684\u8d77\u59cb\u5b57\u8282\u504f\u79fb\u91cf<\/strong>\u3002\u7531\u4e8e\u6d88\u606f\u957f\u5ea6\u4e0d\u5b9a\uff0c\u6b64\u504f\u79fb\u91cf<strong>\u4e0d\u662f\u8fde\u7eed\u7684<\/strong>\u3002<\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td><strong>SysFlag<\/strong><\/td>\n<td>int<\/td>\n<td>4<\/td>\n<td><strong>\u7cfb\u7edf\u6807\u5fd7\u4f4d<\/strong>\uff0c\u662f\u4e00\u4e2a\u4e8c\u8fdb\u5236\u7ec4\u5408\u503c\uff0c\u7528\u4e8e\u6807\u8bc6\u6d88\u606f\u7279\u6027\uff0c\u5982\uff1a\u662f\u5426\u538b\u7f29\u3001\u662f\u5426\u4e3a\u4e8b\u52a1\u6d88\u606f\u3001\u662f\u5426\u7b49\u5f85\u4e8b\u52a1\u63d0\u4ea4\u7b49\u3002<\/td>\n<\/tr>\n<tr>\n<td>9<\/td>\n<td><strong>BornTimestamp<\/strong><\/td>\n<td>long<\/td>\n<td>8<\/td>\n<td><strong>\u6d88\u606f\u751f\u6210\u65f6\u95f4\u6233<\/strong>\uff0c\u7531Producer\u5ba2\u6237\u7aef\u5728\u53d1\u9001\u65f6\u751f\u6210\u3002<\/td>\n<\/tr>\n<tr>\n<td>10<\/td>\n<td><strong>BornHost<\/strong><\/td>\n<td>8\u5b57\u8282<\/td>\n<td>8<\/td>\n<td><strong>\u6d88\u606f\u53d1\u9001\u8005\u5730\u5740<\/strong>\u3002\u5176\u7f16\u7801\u5e76\u975e\u7b80\u5355\u5b57\u7b26\u4e32\uff0c\u800c\u662f\u5c06IP\u76844\u4e2a\u6bb5\u548c\u7aef\u53e3\u53f7\u76842\u4e2a\u5b57\u8282\uff0c\u51716\u4e2a\u5b57\u8282\uff0c\u6309\u5927\u7aef\u5e8f\u7ec4\u5408\u5e76\u586b\u5145\u52308\u5b57\u8282\u4e2d\u3002<\/td>\n<\/tr>\n<tr>\n<td>11<\/td>\n<td><strong>StoreTimestamp<\/strong><\/td>\n<td>long<\/td>\n<td>8<\/td>\n<td><strong>\u6d88\u606f\u5b58\u50a8\u65f6\u95f4\u6233<\/strong>\uff0c\u5373Broker\u6536\u5230\u6d88\u606f\u5e76\u5199\u5165\u5185\u5b58\u7684\u65f6\u95f4\u3002<\/td>\n<\/tr>\n<tr>\n<td>12<\/td>\n<td><strong>StoreHost<\/strong><\/td>\n<td>8\u5b57\u8282<\/td>\n<td>8<\/td>\n<td><strong>Broker\u5b58\u50a8\u5730\u5740<\/strong>\uff0c\u7f16\u7801\u65b9\u5f0f\u540cBornHost\u3002<\/td>\n<\/tr>\n<tr>\n<td>13<\/td>\n<td><strong>ReconsumeTimes<\/strong><\/td>\n<td>int<\/td>\n<td>4<\/td>\n<td><strong>\u6d88\u606f\u91cd\u8bd5\u6d88\u8d39\u6b21\u6570<\/strong>\uff0c\u7528\u4e8e\u6b7b\u4fe1\u961f\u5217\u5224\u65ad\u3002<\/td>\n<\/tr>\n<tr>\n<td>14<\/td>\n<td><strong>PreparedTransationOffset<\/strong><\/td>\n<td>long<\/td>\n<td>8<\/td>\n<td><strong>\u4e8b\u52a1\u6d88\u606f\u4e13\u7528<\/strong>\uff0c\u5b58\u50a8\u4e0e\u4e4b\u5173\u8054\u7684<strong>\u4e8b\u52a1\u65e5\u5fd7\uff08Transaction Log\uff09\u7684\u504f\u79fb\u91cf<\/strong>\u3002<\/td>\n<\/tr>\n<tr>\n<td>15<\/td>\n<td><strong>BodyLength<\/strong><\/td>\n<td>int<\/td>\n<td>4<\/td>\n<td><strong>\u6d88\u606f\u4f53\u5b9e\u9645\u957f\u5ea6<\/strong>\uff0c\u540e\u8ddfBody\u5185\u5bb9\u3002<\/td>\n<\/tr>\n<tr>\n<td>16<\/td>\n<td><strong>Body<\/strong><\/td>\n<td>byte[]<\/td>\n<td>\u4e0d\u5b9a<\/td>\n<td><strong>\u6d88\u606f\u4f53\u5185\u5bb9<\/strong>\uff0c\u5373Producer\u53d1\u9001\u7684\u539f\u59cb\u4e1a\u52a1\u6570\u636e\u3002<\/td>\n<\/tr>\n<tr>\n<td>17<\/td>\n<td><strong>TopicLength<\/strong><\/td>\n<td>byte<\/td>\n<td>1<\/td>\n<td><strong>Topic\u540d\u79f0\u7684\u957f\u5ea6<\/strong>\uff081\u5b57\u8282\uff0c\u56e0\u6b64Topic\u540d\u4e0d\u80fd\u8d85\u8fc7255\u5b57\u7b26\uff09\u3002<\/td>\n<\/tr>\n<tr>\n<td>18<\/td>\n<td><strong>Topic<\/strong><\/td>\n<td>byte[]<\/td>\n<td>\u4e0d\u5b9a<\/td>\n<td><strong>Topic\u540d\u79f0<\/strong>\u7684\u5b57\u8282\u6570\u7ec4\u3002<\/td>\n<\/tr>\n<tr>\n<td>19<\/td>\n<td><strong>PropertiesLength<\/strong><\/td>\n<td>short<\/td>\n<td>2<\/td>\n<td><strong>\u6d88\u606f\u5c5e\u6027\u957f\u5ea6<\/strong>\uff0c\u540e\u8ddfProperties\u5185\u5bb9\u3002<\/td>\n<\/tr>\n<tr>\n<td>20<\/td>\n<td><strong>Properties<\/strong><\/td>\n<td>byte[]<\/td>\n<td>\u4e0d\u5b9a<\/td>\n<td><strong>\u6d88\u606f\u5c5e\u6027<\/strong>\uff0c\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u81ea\u5b9a\u4e49\u7684Key-Value\u6269\u5c55\u4fe1\u606f\u3002\u5728\u7f16\u7801\u65f6\uff0cKey\u548cValue\u4e4b\u95f4\u7528\u7279\u6b8a<strong>\u4e0d\u53ef\u89c1\u5b57\u7b26<\/strong>\uff08\u5982\/u0001\uff09\u5206\u9694\uff0c\u56e0\u6b64\u5c5e\u6027\u4e2d\u4e0d\u80fd\u5305\u542b\u8fd9\u4e9b\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>ConsumeQueue<\/strong><\/p>\n<p>\u6d88\u606f\u6d88\u8d39\u7d22\u5f15\uff0c<strong>\u5f15\u5165\u7684\u76ee\u7684\u4e3b\u8981\u662f\u63d0\u9ad8\u6d88\u606f\u6d88\u8d39\u7684\u6027\u80fd\u3002<\/strong> \u7531\u4e8eRocketMQ\u662f\u57fa\u4e8e\u4e3b\u9898topic\u7684\u8ba2\u9605\u6a21\u5f0f\uff0c\u6d88\u606f\u6d88\u8d39\u662f\u9488\u5bf9\u4e3b\u9898\u8fdb\u884c\u7684\uff0c\u5982\u679c\u8981\u904d\u5386commitlog\u6587\u4ef6\uff0c<strong>\u6839\u636etopic\u68c0\u7d22\u6d88\u606f\u662f\u975e\u5e38\u4f4e\u6548\u7684\u3002<\/strong><\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u4e2d\uff0c\u63d0\u9ad8\u6d88\u8d39\u65f6\u5019\u7684\u901f\u5ea6\uff0cRocketMQ\u4f1a\u542f\u52a8\u540e\u53f0\u7684 dispatch \u7ebf\u7a0b\u6e90\u6e90\u4e0d\u65ad\u7684\u5c06\u6d88\u606f\u4ece commitLog \u53d6\u51fa\u6d88\u606f\u5728 CommitLog \u4e2d\u7684\u7269\u7406\u504f\u79fb\u91cf\uff0c\u6d88\u606f\u957f\u5ea6\u4ee5\u53ca Tag Hash \u7b49\u4fe1\u606f\u4f5c\u4e3a\u5355\u6761\u6d88\u606f\u7684\u7d22\u5f15\uff0c\u5206\u53d1\u5230\u5bf9\u5e94\u7684\u6d88\u8d39\u961f\u5217\uff0c\u6784\u6210\u4e86\u5bf9 CommitLog \u7684\u5f15\u7528\u3002<\/p>\n<p>consumer\u53ef\u6839\u636eConsumeQueue\u6765\u67e5\u627e\u5f85\u6d88\u8d39\u7684\u6d88\u606f\u3002\u5176\u4e2d\uff0cConsumeQueue\u4f5c\u4e3a\u6d88\u8d39\u6d88\u606f\u7684\u7d22\u5f15\uff0c\u4fdd\u5b58\u4e86\u6307\u5b9aTopic\u4e0b\u7684\u961f\u5217\u6d88\u606f\u5728CommitLog\u4e2d\u7684\u8d77\u59cb<strong>\u7269\u7406\u504f\u79fb\u91cfoffset\uff0c\u6d88\u606f\u5927\u5c0fsize\u548c\u6d88\u606fTag\u7684HashCode\u503c\u3002<\/strong><\/p>\n<p><strong>consumequeue\u6587\u4ef6\u53ef\u4ee5\u770b\u6210\u662f\u57fa\u4e8etopic\u7684commitlog\u7d22\u5f15\u6587\u4ef6\uff0c<\/strong> \u6545consumequeue\u6587\u4ef6\u5939\u7684\u7ec4\u7ec7\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p>$HOME\/store\/consumequeue\/{topic}\/{queueId}\/{fileName}<\/p>\n<p><strong>consumequeue\u6587\u4ef6\u91c7\u53d6\u5b9a\u957f\u8bbe\u8ba1\uff0c<\/strong> \u6bcf\u4e00\u4e2a\u6761\u76ee\u517120\u4e2a\u5b57\u8282\uff0c\u524d8\u5b57\u8282\u7684commitlog\u7269\u7406\u504f\u79fb\u91cf\u3001\u4e2d\u95f44\u5b57\u8282\u7684\u6d88\u606f\u957f\u5ea6\u30018\u5b57\u8282tag\u7684hashcode\u3002<\/p>\n<p><img decoding=\"async\" width=\"665\" height=\"285\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdnwdQ\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><strong>indexFile<\/strong><\/p>\n<p>RocketMQ\u7684IndexFile\u7d22\u5f15\u6587\u4ef6\u63d0\u4f9b\u4e86\u901a\u8fc7\u6d88\u606fKey\u6216\u65f6\u95f4\u533a\u95f4\u67e5\u8be2\u6d88\u606f\u7684\u80fd\u529b\uff0c\u5176\u5b58\u50a8\u8def\u5f84\u4e3a$HOME\/store\/index\/{fileName}\uff0c\u5176\u4e2d\u6587\u4ef6\u540d\u4ee5\u521b\u5efa\u65f6\u95f4\u6233\u547d\u540d\u3002\u5355\u4e2aIndexFile\u6587\u4ef6\u5927\u5c0f\u56fa\u5b9a\u7ea6\u4e3a400M\uff0c\u53ef\u4fdd\u5b582000W\u4e2a\u7d22\u5f15\uff0c\u5176\u5e95\u5c42\u91c7\u7528\u7c7bHashMap\u7684\u54c8\u5e0c\u7d22\u5f15\u7ed3\u6784\u5b9e\u73b0\u3002<\/p>\n<p>IndexFile\u662f\u4e00\u4e2a<strong>\u56fa\u5b9a\u5927\u5c0f<\/strong>\u7684\u6587\u4ef6\uff08\u7ea6400MB\uff09\uff0c\u5176\u7269\u7406\u7ed3\u6784\u7531\u4e09\u90e8\u5206\u7ec4\u6210<\/p>\n<p><img decoding=\"async\" width=\"636\" height=\"142\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdnwdS\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>1.IndexHeader\uff08\u7d22\u5f15\u5934\uff0c40\u5b57\u8282\uff09<\/p>\n<p><strong>beginTimestamp\uff1a<\/strong> \u7b2c\u4e00\u6761\u6d88\u606f\u5b58\u50a8\u65f6\u95f4<\/p>\n<p><strong>endTimestamp\uff1a<\/strong> \u6700\u540e\u4e00\u6761\u6d88\u606f\u5b58\u50a8\u65f6\u95f4<\/p>\n<p><strong>beginPhyoffset\uff1a<\/strong> \u7b2c\u4e00\u6761\u6d88\u606f\u5728CommitLog\u4e2d\u7684\u7269\u7406\u504f\u79fb\u91cf<\/p>\n<p><strong>endPhyoffset\uff1a<\/strong> \u6700\u540e\u4e00\u6761\u6d88\u606f\u5728CommitLog\u4e2d\u7684\u7269\u7406\u504f\u79fb\u91cf<\/p>\n<p><strong>hashSlotCount\uff1a<\/strong> \u5df2\u4f7f\u7528\u7684\u54c8\u5e0c\u69fd\u6570\u91cf<\/p>\n<p><strong>indexCount\uff1a<\/strong> \u7d22\u5f15\u5355\u5143\u603b\u6570<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"124\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdnwdU\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>2.Slots\uff08\u54c8\u5e0c\u69fd\uff09<\/p>\n<p>\u6bcf\u4e2aIndexFile\u5305\u542b500\u4e07\u4e2a\u54c8\u5e0c\u69fd\u4f4d,\u6bcf\u4e2aSlot\u69fd\u4f4d\uff084\u5b57\u8282\uff09\u5b58\u50a8\u7684\u662f\u94fe\u5f0f\u7d22\u5f15\u7684\u7b2c\u4e00\u4e2a\u7d22\u5f15\u5e8f\u53f7\uff0c\u6bcf\u4e2a\u69fd\u4f4d\u53ef\u6302\u8f7d\u591a\u4e2a\u7d22\u5f15\u5355\u5143\uff0c\u5f62\u6210\u94fe\u5f0f\u7ed3\u6784\u3002<\/p>\n<ul>\n<li>\u5982\u679cSlot\u503c\u4e3a0\uff1a\u8868\u793a\u8be5\u69fd\u4f4d\u6ca1\u6709\u7d22\u5f15\u94fe<\/li>\n<li>\u5982\u679cSlot\u503c\u4e3aN\uff1a\u8868\u793a\u8be5\u69fd\u4f4d\u5bf9\u5e94\u7684\u7d22\u5f15\u94fe\u5934\u8282\u70b9\u7d22\u5f15\u5e8f\u53f7\u4e3aN<\/li>\n<\/ul>\n<p>3.Indexes\uff08\u7d22\u5f15\u5355\u5143\uff0c20\u5b57\u8282\/\u4e2a\uff09<\/p>\n<p>\u6bcf\u4e2a\u7d22\u5f15\u5355\u5143\u5305\u542b\u4ee5\u4e0b\u5b57\u6bb5\uff1a<\/p>\n<ul>\n<li><strong>keyHash\uff1a<\/strong> \u6d88\u606fKey\u7684\u54c8\u5e0c\u503c<\/li>\n<li><strong>phyOffset\uff1a<\/strong> \u6d88\u606f\u5728CommitLog\u4e2d\u7684\u7269\u7406\u504f\u79fb\u91cf<\/li>\n<li><strong>timeDiff\uff1a<\/strong> \u6d88\u606f\u5b58\u50a8\u65f6\u95f4\u4e0eIndexFile\u521b\u5efa\u65f6\u95f4\u7684\u5dee\u503c<\/li>\n<li><strong>preIndexNo\uff1a<\/strong> \u540c\u4e00\u54c8\u5e0c\u69fd\u4e2d\u524d\u4e00\u4e2a\u7d22\u5f15\u5355\u5143\u7684\u5e8f\u53f7<\/li>\n<\/ul>\n<p><img decoding=\"async\" width=\"723\" height=\"349\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdnwdV\" alt=\"\" title=\"\" loading=\"lazy\"><br \/>\u8fd9\u4e2a\u7ed3\u6784\u548chashmap\u7ed3\u6784\u5f88\u50cf\uff0c\u4f46\u662f\u652f\u6301\u6bcf\u4e2akey\u901a\u8fc7\u65f6\u95f4\u6392\u5e8f\uff0c\u5c31\u53ef\u4ee5\u8fdb\u884c\u65f6\u95f4\u8303\u56f4\u7684\u68c0\u7d22\u3002<\/p>\n<p>\u901a\u8fc7\u5b9a\u957f\u7d22\u5f15\u7ed3\u6784\u548c\u6574\u4f53\u8bbe\u8ba1\u53ef\u4ee5\u901a\u8fc7key\u5feb\u901f\u5b9a\u4f4d\u7d22\u5f15\u6570\u636e\uff0c\u62ff\u5230\u771f\u5b9e\u6570\u636e\u7684\u7269\u7406\u504f\u79fb\u91cf\u3002<\/p>\n<p>4.\u7d22\u5f15\u67e5\u8be2\u6d41\u7a0b<\/p>\n<p>\u6d88\u8d39\u8005\u901a\u8fc7\u6d88\u606fKey\u67e5\u8be2\u65f6\uff0c\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u8ba1\u7b97\u69fd\u4f4d\u5e8f\u53f7slot\u5e8f\u53f7 = key\u54c8\u5e0c\u503c % 500\u4e07<\/li>\n<li>\u5b9a\u4f4d\u69fd\u4f4d\u5730\u5740slot\u4f4d\u7f6e = 40 + (slot\u5e8f\u53f7 &#8211; 1) \u00d7 4<\/li>\n<li>\u83b7\u53d6\u9996\u4e2a\u7d22\u5f15\u4f4d\u7f6eindex\u4f4d\u7f6e = 40 + 500\u4e07 \u00d7 4 + (\u7d22\u5f15\u5e8f\u53f7 &#8211; 1) \u00d7 20<\/li>\n<li>\u904d\u5386\u7d22\u5f15\u94fe\u4ece\u69fd\u4f4d\u6307\u5411\u7684\u7d22\u5f15\u5f00\u59cb\uff0c\u6cbfpreIndexNo\u94fe\u5f0f\u67e5\u627e\uff0c\u5339\u914d\u76ee\u6807Key\u5e76\u6821\u9a8c\u65f6\u95f4\u8303\u56f4<\/li>\n<li>\u83b7\u53d6\u7269\u7406\u504f\u79fb\u91cf\u4ece\u5339\u914d\u7684\u7d22\u5f15\u5355\u5143\u4e2d\u8bfb\u53d6phyOffset\uff0c\u6700\u7ec8\u4eceCommitLog\u83b7\u53d6\u5b8c\u6574\u6d88\u606f\u5185\u5bb9<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u6b64\u673a\u5236\uff0cIndexFile\u5b9e\u73b0\u4e86\u57fa\u4e8eKey\u7684\u9ad8\u6548\u70b9\u67e5\u548c\u57fa\u4e8e\u65f6\u95f4\u8303\u56f4\u7684\u5feb\u901f\u68c0\u7d22\u3002<\/p>\n<p><strong>\u6574\u4f53\u6d41\u7a0b<\/strong><\/p>\n<p>RocketMQ \u9ad8\u6027\u80fd\u5b58\u50a8\u7684\u6838\u5fc3\uff0c\u5728\u4e8e\u5176\u00a0<strong>\u201c\u6df7\u5408\u5b58\u50a8\u201d<\/strong> \u67b6\u6784\uff0c\u8fd9\u6b63\u662f\u4e00\u79cd\u7cbe\u5999\u7684<strong>\u5b58\u50a8\u5c42\u8bfb\u5199\u5206\u79bb<\/strong>\u8bbe\u8ba1\u3002<\/p>\n<p>\u5176\u5de5\u4f5c\u6d41\u7a0b\u53ef\u4ee5\u8fd9\u6837\u7406\u89e3\uff1a<\/p>\n<ol>\n<li><strong>\u7edf\u4e00\u5199\u5165\uff0c\u4fdd\u8bc1\u6781\u81f4\u6027\u80fd\uff1a<\/strong> \u6240\u6709\u6d88\u606f\u987a\u5e8f\u8ffd\u52a0\u5199\u5165\u4e00\u4e2a\u7edf\u4e00\u7684\u00a0CommitLog\u00a0\u6587\u4ef6\u3002\u8fd9\u79cd\u5355\u4e00\u7684\u987a\u5e8f\u5199\u64cd\u4f5c\uff0c\u662f\u5b83\u80fd\u627f\u53d7\u6d77\u91cf\u6d88\u606f\u5199\u5165\u7684\u6839\u672c\u3002<\/li>\n<li><strong>\u5f02\u6b65\u6784\u5efa\uff0c\u4f18\u5316\u8bfb\u53d6\u8def\u5f84\uff1a<\/strong> \u6d88\u606f\u4e00\u65e6\u6301\u4e45\u5316\u81f3\u00a0CommitLog\uff0c\u5373\u89c6\u4e3a\u5b89\u5168\u3002\u968f\u540e\uff0c\u540e\u53f0\u670d\u52a1\u7ebf\u7a0b\u4f1a\u5f02\u6b65\u5730\u6784\u5efa\u51fa\u4e13\u4f9b\u6d88\u8d39\u7684\u00a0ConsumerQueue\uff08\u903b\u8f91\u961f\u5217\u7d22\u5f15\uff09\u548c\u7528\u4e8e\u67e5\u8be2\u7684\u00a0IndexFile\u3002\u8fd9\u76f8\u5f53\u4e8e\u4e3a\u6570\u636e\u5efa\u7acb\u4e86\u9ad8\u6548\u7684\u201c\u76ee\u5f55\u201d\u3002<\/li>\n<li><strong>\u6d88\u8d39\u6d88\u606f\uff1a<\/strong> \u6d88\u8d39\u8005\u5b9e\u9645\u62c9\u53d6\u6d88\u606f\u65f6\uff0c\u662f\u5148\u8bfb\u53d6\u00a0ConsumerQueue\u00a0\u627e\u5230\u6d88\u606f\u5728\u00a0CommitLog\u00a0\u4e2d\u7684\u7269\u7406\u4f4d\u7f6e\uff0c\u518d\u53cd\u67e5\u00a0CommitLog\u00a0\u83b7\u53d6\u5b8c\u6574\u6d88\u606f\u5185\u5bb9\u3002<\/li>\n<li><strong>\u53ef\u9760\u7684\u6d88\u8d39\u673a\u5236\uff1a<\/strong> \u57fa\u4e8e\u4e0a\u8ff0\u6301\u4e45\u5316\u4fdd\u969c\uff0c\u914d\u5408\u6d88\u8d39\u8005\u81ea\u8eab\u7684\u504f\u79fb\u91cf\u7ba1\u7406\u53caBroker\u7684\u957f\u8f6e\u8be2\u673a\u5236\uff0c\u5171\u540c\u5b9e\u73b0\u4e86\u6d88\u606f\u7684\u53ef\u9760\u6295\u9012\u4e0e\u9ad8\u6548\u83b7\u53d6\u3002<\/li>\n<\/ol>\n<p>\u8fd9\u79cd <strong>\u201c\u8bfb\u5199\u5206\u79bb\u201d<\/strong> \u8bbe\u8ba1\u7684\u597d\u5904\u5728\u4e8e\uff1a\u5c06\u8017\u65f6\u7684\u5199\u64cd\u4f5c\uff08\u987a\u5e8f\u5199CommitLog\uff09\u4e0e\u590d\u6742\u7684\u8bfb\u64cd\u4f5c\uff08\u6784\u5efa\u7d22\u5f15\u3001\u5206\u6563\u67e5\u8be2\uff09\u89e3\u8026\uff0c\u8ba9\u4e24\u8005\u53ef\u4ee5\u5f02\u6b65\u3001\u72ec\u7acb\u5730\u8fdb\u884c\u4f18\u5316\uff0c\u4ece\u800c\u5728\u6574\u4f53\u4e0a\u83b7\u5f97\u66f4\u9ad8\u7684\u541e\u5410\u91cf\u548c\u66f4\u4f4e\u7684\u5ef6\u8fdf\u3002\u8fd9\u4f53\u73b0\u4e86\u201c\u5404\u53f8\u5176\u804c\uff0c\u5f02\u6b65\u534f\u540c\u201d\u7684\u7ecf\u5178\u67b6\u6784\u601d\u60f3\u3002<\/p>\n<p>\u4e0b\u56fe\u662f\u5b98\u65b9\u6587\u6863\u7684\u6d41\u7a0b\u56fe<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"573\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdnwdY\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5199\u5165\u6d41\u7a0b<\/p>\n<p><strong>1.\u6d88\u606f\u9884\u5904\u7406<\/strong><\/p>\n<p><strong>\u57fa\u7840\u6821\u9a8c\uff1a<\/strong> \u68c0\u67e5Topic\u540d\u79f0\u3001\u6d88\u606f\u4f53\u957f\u5ea6\u7b49\u662f\u5426\u5408\u6cd5\u3002<\/p>\n<p><strong>\u751f\u6210\u552f\u4e00ID\uff1a<\/strong> \u7ed3\u5408Broker\u5730\u5740\u548cCommitLog\u504f\u79fb\u91cf\u7b49\uff0c\u751f\u6210\u5168\u5c40\u552f\u4e00\u7684MsgID\u3002<\/p>\n<p><strong>\u8bbe\u7f6e\u7cfb\u7edf\u6807\u5fd7\uff1a<\/strong> \u6839\u636e\u6d88\u606f\u5c5e\u6027\uff08\u5982\u662f\u5426\u4e8b\u52a1\u6d88\u606f\u3001\u662f\u5426\u538b\u7f29\uff09\u8bbe\u7f6eSysFlag\u3002<\/p>\n<p><strong>2.CommitLog\u6838\u5fc3\u5199\u5165<\/strong><\/p>\n<p><strong>\u83b7\u53d6MappedFile\uff1a<\/strong> \u6839\u636e\u5f53\u524d\u5199\u5165\u4f4d\u7f6e\uff0c\u5b9a\u4f4d\u6216\u521b\u5efa\u5bf9\u5e94\u76841GB\u5185\u5b58\u6620\u5c04\u6587\u4ef6\u3002\u8fd9\u91cc\u91c7\u7528\u53cc\u91cd\u68c0\u67e5\u9501\u6a21\u5f0f\u6765\u4fdd\u8bc1\u6027\u80fd\u548c\u5b89\u5168\u3002<\/p>\n<p><strong>\u4e32\u884c\u52a0\u9501\u5199\u5165\uff1a<\/strong> \u83b7\u53d6\u5168\u5c40\u6216\u6587\u4ef6\u7ea7\u9501\uff08PutMessageLock\uff09\uff0c\u786e\u4fdd\u540c\u4e00\u65f6\u523b\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u5199\u5165\u6587\u4ef6\uff0c\u4e25\u683c\u4fdd\u8bc1<strong>\u987a\u5e8f\u6027\u3002<\/strong><\/p>\n<p><strong>\u5e8f\u5217\u5316\u4e0e\u8ffd\u52a0\uff1a<\/strong> \u5c06\u6d88\u606f\u6309\u7167\u4e4b\u524d\u5206\u6790\u7684<strong>\u4e8c\u8fdb\u5236\u534f\u8bae\uff0c<\/strong> \u5e8f\u5217\u5316\u5230MappedByteBuffer\u4e2d\uff0c\u5e76\u66f4\u65b0\u5199\u5165\u6307\u9488\u3002<\/p>\n<p><strong>3.\u5237\u76d8\uff08Flush\uff09<\/strong><\/p>\n<p><strong>\u540c\u6b65\u5237\u76d8\uff1a<\/strong> \u6d88\u606f\u5199\u5165\u5185\u5b58\u6620\u5c04\u533a\u540e\uff0c\u4f1a\u521b\u5efa\u4e00\u4e2aGroupCommitRequest\u5e76\u653e\u5165\u8bf7\u6c42\u7ec4\u3002\u5199\u5165\u7ebf\u7a0b\u4f1a\u7b49\u5f85\uff0c\u76f4\u5230<strong>\u5237\u76d8\u7ebf\u7a0b<\/strong>\u5b8c\u6210\u8be5\u8bf7\u6c42\u5bf9\u5e94\u6587\u4ef6\u7684\u7269\u7406\u5237\u76d8\u540e\uff0c\u624d\u8fd4\u56de\u6210\u529f\u7ed9Producer\u3002<strong>\u6570\u636e\u6700\u53ef\u9760\uff0c\u4f46\u5ef6\u8fdf\u8f83\u9ad8\u3002<\/strong><\/p>\n<p><strong>\u5f02\u6b65\u5237\u76d8\uff08\u9ed8\u8ba4\uff09\uff1a<\/strong> \u6d88\u606f\u5199\u5165\u5185\u5b58\u6620\u5c04\u533a\u540e\uff0c\u7acb\u5373\u8fd4\u56de\u6210\u529f\u7ed9Producer\u3002\u540c\u65f6\u5524\u9192<strong>\u5f02\u6b65\u5237\u76d8\u7ebf\u7a0b\uff0c<\/strong> \u8be5\u7ebf\u7a0b\u4f1a\u5b9a\u65f6\u6216\u5f53PageCache\u4e2d\u5f85\u5237\u76d8\u6570\u636e\u79ef\u7d2f\u5230\u4e00\u5b9a\u91cf\u65f6\uff0c\u6267\u884c\u4e00\u6b21\u6279\u91cf\u5237\u76d8\u3002<strong>\u6027\u80fd\u9ad8\uff0c\u4f46\u6709\u5b95\u673a\u4e22\u6570\u98ce\u9669\u3002<\/strong><\/p>\n<p><strong>4.\u5f02\u6b65\u7d22\u5f15\u6784\u5efa<\/strong><\/p>\n<p>\u7531\u72ec\u7acb\u7684ReputMessageService\u7ebf\u7a0b\u5904\u7406\u3002\u5b83\u4e0d\u65ad\u68c0\u67e5CommitLog\u4e2d\u662f\u5426\u6709\u65b0\u6d88\u606f\u5230\u8fbe\u3002<\/p>\n<p>\u4e00\u65e6\u6709<strong>\u65b0\u6d88\u606f\u88ab\u786e\u8ba4\u6301\u4e45\u5316<\/strong>\uff08\u5bf9\u4e8e\u540c\u6b65\u5237\u76d8\u662f\u5df2\u843d\u76d8\uff0c\u5bf9\u4e8e\u5f02\u6b65\u5237\u76d8\u662f\u5df2\u5199\u5165\u6620\u5c04\u533a\uff09\uff0c\u8be5\u7ebf\u7a0b\u5c31\u4f1a\u8bfb\u53d6\u6d88\u606f\u5185\u5bb9\u3002<\/p>\n<p>\u968f\u540e\uff0c\u5b83\u4f1a\u4e3a\u8fd9\u6761\u6d88\u606f\u5728\u5bf9\u5e94\u7684consumequeue\u76ee\u5f55\u4e0b\u6784\u5efa<strong>\u6d88\u8d39\u961f\u5217\u7d22\u5f15<\/strong>\uff08\u8bb0\u5f55CommitLog\u7269\u7406\u504f\u79fb\u91cf\u548c\u6d88\u606f\u957f\u5ea6\uff09\uff0c\u66f4\u65b0index\u7d22\u5f15\u6587\u4ef6\u3002<\/p>\n<p>\u6d88\u8d39\u6d41\u7a0b<\/p>\n<p><strong>1.\u542f\u52a8\u4e0e\u8d1f\u8f7d\u5747\u8861<\/strong><\/p>\n<p>\u6d88\u8d39\u8005\u542f\u52a8\u540e\uff0c\u4f1a\u5411<strong>NameServer<\/strong>\u83b7\u53d6Topic\u7684\u8def\u7531\u4fe1\u606f\uff08\u5305\u542b\u54ea\u4e9b\u961f\u5217\u3001\u5206\u5e03\u5728\u54ea\u4e9bBroker\u4e0a\uff09\u3002<\/p>\n<p>\u5982\u679c\u6d88\u8d39\u8005\u7ec4\u5185\u6709\u591a\u4e2a\u5b9e\u4f8b\uff0c\u4f1a\u89e6\u53d1<strong>\u961f\u5217\u8d1f\u8f7d\u5747\u8861<\/strong>\uff08\u9ed8\u8ba4\u7b56\u7565\u662f\u5e73\u5747\u5206\u914d\uff09\u3002\u4f8b\u5982\uff0c\u4e00\u4e2aTopic\u67098\u4e2a\u961f\u5217\uff0c\u4e24\u4e2a\u6d88\u8d39\u8005\u5b9e\u4f8b\uff0c\u5219\u901a\u5e38\u6bcf\u4e2a\u6d88\u8d39\u8005\u8d1f\u8d23\u6d88\u8d394\u4e2a\u961f\u5217\u3002\u8fd9\u4e00\u6b65\u51b3\u5b9a\u4e86\u6bcf\u4e2a\u6d88\u8d39\u8005\u201c\u8ba4\u9886\u201d\u4e86\u54ea\u4e9b\u6d88\u606f\u961f\u5217\u3002<\/p>\n<p><strong>2.\u62c9\u53d6\u6d88\u606f\u5faa\u73af<\/strong><\/p>\n<p>\u6bcf\u4e2a\u6d88\u8d39\u8005\u5b9e\u4f8b\u5185\u90e8\u90fd\u6709\u4e00\u4e2aPullMessageService\u7ebf\u7a0b\uff0c\u5b83\u5faa\u73af\u4ece\u4e00\u4e2aPullRequest\u961f\u5217\u4e2d\u83b7\u53d6\u4efb\u52a1\u3002<\/p>\n<p>PullRequest\u5305\u542b\u4e86\u62c9\u53d6\u76ee\u6807\uff08\u5982Broker-A\uff0c\u00a0\u961f\u52173\uff09\u4ee5\u53ca<strong>\u4e0b\u4e00\u6b21\u8981\u62c9\u53d6\u7684\u4f4d\u70b9\uff08offset\uff09\u3002<\/strong><\/p>\n<p>\u6d88\u8d39\u8005\u5411\u6307\u5b9a\u7684Broker\u53d1\u9001\u7f51\u7edc\u8bf7\u6c42\uff0c\u8bf7\u6c42\u4f53\u4e2d\u5c31\u643a\u5e26\u4e86\u8fd9\u4e2aoffset\u3002<\/p>\n<p><strong>3.Broker\u7aef\u5904\u7406\u4e0e\u8fd4\u56de<\/strong><\/p>\n<p>Broker\u6536\u5230\u8bf7\u6c42\u540e\uff0c\u6839\u636eTopic\u3001\u961f\u5217ID\u548coffset\uff0c\u53bb\u67e5\u8be2\u5bf9\u5e94\u7684<strong>ConsumeQueue\u7d22\u5f15\u6587\u4ef6\u3002<\/strong><\/p>\n<p>ConsumeQueue\u4e2d\u5b58\u50a8\u7684\u662f\u5b9a\u957f\uff0820\u5b57\u8282\uff09\u7684\u8bb0\u5f55\uff0c\u5305\u542b\u6d88\u606f\u5728<strong>CommitLog\u4e2d\u7684\u7269\u7406\u504f\u79fb\u91cf\u548c\u957f\u5ea6\u3002<\/strong><\/p>\n<p>Broker\u6839\u636e\u7269\u7406\u504f\u79fb\u91cf\uff0c\u4ece<strong>CommitLog\u6587\u4ef6<\/strong>\u4e2d\u8bfb\u53d6\u5b8c\u6574\u7684\u6d88\u606f\u5185\u5bb9\uff0c\u901a\u8fc7\u7f51\u7edc\u8fd4\u56de\u7ed9\u6d88\u8d39\u8005\u3002<\/p>\n<p><strong>4.\u6d88\u606f\u5904\u7406\u4e0e\u4f4d\u70b9\u63d0\u4ea4<\/strong><\/p>\n<p>\u6d88\u8d39\u8005\u5c06\u62c9\u53d6\u5230\u7684\u6d88\u606f\u63d0\u4ea4\u5230\u5185\u90e8\u7684<strong>\u6d88\u8d39\u7ebf\u7a0b\u6c60<\/strong>\u8fdb\u884c\u5904\u7406\uff0c\u4f60\u7684\u4e1a\u52a1\u903b\u8f91\u5c31\u5728\u8fd9\u91cc\u6267\u884c\u3002<\/p>\n<p><strong>\u6d88\u8d39\u4f4d\u70b9\u7684\u7ba1\u7406\u81f3\u5173\u91cd\u8981\uff1a<\/strong><\/p>\n<p><strong>\u4f4d\u70b9\u5b58\u50a8\uff1a<\/strong> \u4f4d\u70b9\u7531OffsetStore\u7ba1\u7406\u3002\u5728<strong>\u96c6\u7fa4\u6a21\u5f0f\uff08CLUSTER\uff09<\/strong>\u00a0\u4e0b\uff0c\u6d88\u8d39\u4f4d\u70b9\u5b58\u50a8\u5728Broker\u4e0a\uff1b\u5728<strong>\u5e7f\u64ad\u6a21\u5f0f\uff08BROADCAST\uff09<\/strong> \u4e0b\uff0c\u4f4d\u70b9\u5b58\u50a8\u5728\u672c\u5730\u3002<\/p>\n<p><strong>\u4f4d\u70b9\u63d0\u4ea4\uff1a<\/strong> \u6d88\u8d39\u6210\u529f\u540e\uff0c\u6d88\u8d39\u8005\u4f1a<strong>\u5f02\u6b65<\/strong>\uff08\u9ed8\u8ba4\u65b9\u5f0f\uff09\u5411Broker\u63d0\u4ea4\u5df2\u6d88\u8d39\u7684\u4f4d\u70b9\u3002Broker\u5c06\u5176\u6301\u4e45\u5316\u5230store\/config\/consumerOffset.json\u6587\u4ef6\u4e2d\u3002<\/p>\n<p><strong>5.\u6d88\u606f\u91cd\u8bd5\u4e0e\u6b7b\u4fe1<\/strong><\/p>\n<p>\u5982\u679c\u6d88\u606f\u6d88\u8d39<strong>\u5931\u8d25<\/strong>\uff08\u629b\u51fa\u5f02\u5e38\u6216\u8d85\u65f6\u672a\u8fd4\u56deCONSUME_SUCCESS\uff09\uff0cRocketMQ\u4f1a\u89e6\u53d1<strong>\u91cd\u8bd5\u673a\u5236\u3002<\/strong><\/p>\n<p>\u5bf9\u4e8e\u666e\u901a\u6d88\u606f\uff0c\u6d88\u606f\u4f1a\u88ab\u53d1\u56deBroker\u4e0a\u4e00\u4e2a\u7279\u6b8a\u7684<strong>\u91cd\u8bd5\u4e3b\u9898<\/strong>\uff08%RETRY%&lt;ConsumerGroup&gt;\uff09\uff0c\u5ef6\u8fdf\u4e00\u6bb5\u65f6\u95f4\uff08\u5ef6\u8fdf\u7ea7\u522b\uff1a1s\u30015s\u300110s\u2026\uff09\u540e\u518d\u88ab\u539f\u6d88\u8d39\u8005\u7ec4\u62c9\u53d6\u3002<\/p>\n<p>\u5982\u679c<strong>\u91cd\u8bd5\u8d85\u8fc7\u6700\u5927\u6b21\u6570<\/strong>\uff08\u9ed8\u8ba416\u6b21\uff09\uff0c\u6d88\u606f\u4f1a\u88ab\u6295\u9012\u5230<strong>\u6b7b\u4fe1\u4e3b\u9898<\/strong>\uff08%DLQ%&lt;ConsumerGroup&gt;\uff09\uff0c\u7b49\u5f85\u4eba\u5de5\u5e72\u9884\u3002\u6b7b\u4fe1\u961f\u5217\u4e2d\u7684\u6d88\u606f\u4e0d\u4f1a\u518d\u88ab\u81ea\u52a8\u6d88\u8d39\u3002<\/p>\n<h3>\u4e00\u4f53\u4e0e\u5206\u79bb\uff1aKafka\u548cRocketMQ\u7684\u6838\u5fc3\u67b6\u6784\u535a\u5f08<\/h3>\n<p>\u8bf4\u8d77RocketMQ\u5c31\u4e0d\u80fd\u4e0d\u63d0\u8d77Kafka\u4e86\uff0c\u4e24\u8005\u90fd\u662f\u6d88\u606f\u4e2d\u95f4\u4ef6\u8fd9\u4e2a\u9886\u57df\u7684\u9738\u4e3b\uff0c\u4f46\u5b83\u4eec\u7684\u6838\u5fc3<strong>\u67b6\u6784\u8bbe\u8ba1\u5dee\u5f02\uff0c<\/strong> \u76f4\u63a5\u51b3\u5b9a\u4e86\u5404\u81ea\u4e0d\u540c\u7684\u6027\u80fd\u7279\u6027\u548c\u9002\u7528\u573a\u666f\uff0c\u8fd9\u4e5f\u662f\u6280\u672f\u9009\u578b\u65f6\u5fc5\u987b\u6df1\u5165\u7406\u89e3\u7684\u91cd\u70b9\u3002<\/p>\n<p><strong>\u6838\u5fc3\u67b6\u6784\u8bbe\u8ba1\u5dee\u5f02<\/strong><\/p>\n<p><strong>Kafka\uff1a\u8bfb\u5199\u4e00\u4f53\u7684\u201c\u5206\u533a\u65e5\u5fd7\u201d\u6a21\u578b\uff0c<\/strong> Kafka\u7684\u67b6\u6784\u54f2\u5b66\u662f<strong>\u6781\u7b80\u4e0e\u7edf\u4e00\u3002<\/strong> \u5b83\u5c06\u6bcf\u4e2a\u4e3b\u9898\u5206\u533a\u62bd\u8c61\u4e3a\u4e00\u4e2a<strong>\u4ec5\u8ffd\u52a0\uff08append-only\uff09\u7684\u7269\u7406\u65e5\u5fd7\u6587\u4ef6\u3002<\/strong> \u751f\u4ea7\u8005\u548c\u6d88\u8d39\u8005\u90fd\u76f4\u63a5\u4e0e\u8fd9\u4e2a\u65e5\u5fd7\u6587\u4ef6\u4ea4\u4e92\uff1a\u751f\u4ea7\u8005\u987a\u5e8f\u5199\u5165\u5c3e\u90e8\uff0c\u6d88\u8d39\u8005\u901a\u8fc7\u7ef4\u62a4\u504f\u79fb\u91cf\u987a\u5e8f\u8bfb\u53d6\u3002\u8fd9\u79cd\u8bbe\u8ba1\u4e0b\uff0c<strong>\u6570\u636e\u7684\u8bfb\u5199\u8def\u5f84\u5b8c\u5168\u4e00\u81f4\uff0c<\/strong> \u903b\u8f91\u4e0e\u7269\u7406\u7ed3\u6784\u9ad8\u5ea6\u7edf\u4e00\u3002<\/p>\n<p><strong>RocketMQ\uff1a\u8bfb\u5199\u5206\u79bb\u7684\u201c\u4e8c\u7ea7\u5236\u201d\u6a21\u578b \uff0c<\/strong> RocketMQ\u7684\u67b6\u6784\u54f2\u5b66\u662f<strong>\u5206\u5de5\u4e0e\u4f18\u5316\u3002<\/strong> \u5b83\u91c7\u7528\u4e86<strong>\u7269\u7406CommitLog + \u903b\u8f91ConsumeQueue\u7684\u4e8c\u7ea7\u7ed3\u6784\u3002<\/strong> \u6240\u6709\u6d88\u606f\u90fd\u987a\u5e8f\u5199\u5165\u4e00\u4e2a\u7edf\u4e00\u7684<strong>CommitLog<\/strong>\u7269\u7406\u6587\u4ef6\uff0c\u5b9e\u73b0\u78c1\u76d8\u7684\u6700\u9ad8\u6548\u987a\u5e8f\u5199\u3002\u540c\u65f6\uff0c\u4e3a\u6bcf\u4e2a\u6d88\u606f\u961f\u5217\u5f02\u6b65\u6784\u5efa\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684<strong>ConsumeQueue<\/strong>\u7d22\u5f15\u6587\u4ef6\uff0c\u6d88\u8d39\u8005\u8bfb\u53d6\u65f6\u5148\u67e5\u8be2\u5185\u5b58\u4e2d\u7684ConsumeQueue\u5b9a\u4f4d\uff0c\u518d\u5230CommitLog\u4e2d\u83b7\u53d6\u6d88\u606f\u4f53\u3002\u8fd9\u662f\u4e00\u79cd<strong>\u903b\u8f91\u4e0e\u7269\u7406\u5206\u79bb<\/strong>\u7684\u8bbe\u8ba1\u3002<\/p>\n<p><strong>\u4f18\u52a3\u52bf\u5bf9\u6bd4<\/strong><\/p>\n<p>\u57fa\u4e8e\u4e0a\u8ff0\u67b6\u6784\u8bbe\u8ba1\u6839\u672c\u5dee\u5f02\uff0c\u4e24\u8005\u5728\u5173\u952e\u6307\u6807\u4e0a\u5404\u663e\u4f18\u52a3\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u7ef4\u5ea6<\/th>\n<th>Kafka\uff08\u8bfb\u5199\u4e00\u4f53\uff09<\/th>\n<th>RocketMQ\uff08\u8bfb\u5199\u5206\u79bb\uff09<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\u6838\u5fc3\u4f18\u52bf<\/strong><\/td>\n<td><strong>\u6781\u81f4\u541e\u5410\u4e0e\u4f4e\u5ef6\u8fdf<\/strong>\uff1a\u8bfb\u5199\u540c\u8def\u5f84\uff0c\u6570\u636e\u5199\u5165\u540e\u7acb\u5373\u53ef\u8bfb\uff0c\u7aef\u5230\u7aef\u5ef6\u8fdf\u6781\u4f4e\u3002<strong>\u67b6\u6784\u7b80\u5355<\/strong>\uff1a\u65e0\u4e2d\u95f4\u72b6\u6001\uff0c\u526f\u672c\u540c\u6b65\u3001\u6545\u969c\u6062\u590d\u903b\u8f91\u6e05\u6670\u3002<\/td>\n<td><strong>\u9ad8\u5e76\u53d1\u8bfb\u4e0e\u4e30\u5bcc\u529f\u80fd<\/strong>\uff1a\u7d22\u5f15\u4e0e\u6570\u636e\u5206\u79bb\uff0c\u652f\u6301\u6d77\u91cf\u6d88\u8d39\u8005\u5e76\u53d1\u8bfb\u3002<strong>\u4e1a\u52a1\u53cb\u597d<\/strong>\uff1a\u539f\u751f\u652f\u6301\u4e8b\u52a1\u6d88\u606f\u3001\u5b9a\u65f6\/\u5ef6\u65f6\u6d88\u606f\u3001\u6d88\u606f\u8f68\u8ff9\u67e5\u8be2\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\u5b58\u50a8\u6548\u7387<\/strong><\/td>\n<td><strong>\u78c1\u76d8\u987a\u5e8fIO\u6700\u5927\u5316<\/strong>\uff1a\u751f\u4ea7\u548c\u6d88\u8d39\u90fd\u662f\u4e25\u683c\u987a\u5e8fIO\uff0c\u5c24\u5176\u9002\u5408\u673a\u68b0\u786c\u76d8\u3002<\/td>\n<td><strong>\u5199\u6027\u80fd\u6781\u81f4\u5316<\/strong>\uff1a\u6240\u6709\u6d88\u606f\u987a\u5e8f\u5199CommitLog\uff0c<strong>\u4f46\u5b58\u5728\u201c\u5199\u653e\u5927\u201d<\/strong> \uff0c\u4e00\u6761\u6d88\u606f\u9700\u5199\u591a\u6b21\uff081\u6b21CommitLog + N\u6b21ConsumeQueue\uff09\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\u8bfb\u6027\u80fd<\/strong><\/td>\n<td><strong>\u6d88\u8d39\u8005\u843d\u540e\u65f6\u53ef\u80fd\u89e6\u53d1\u968f\u673a\u8bfb<\/strong>\uff1a\u82e5\u6d88\u8d39\u8005\u8981\u8bfb\u53d6\u975e\u5c3e\u90e8\u5386\u53f2\u6570\u636e\uff0c\u53ef\u80fd\u9700\u78c1\u76d8\u5bfb\u9053\u3002\u4f46\u73b0\u4ee3SSD\u548c\u9884\u8bfb\u673a\u5236\u5df2\u5927\u5927\u7f13\u89e3\u6b64\u95ee\u9898\u3002<\/td>\n<td><strong>\u8bfb\u8def\u5f84\u4f18\u5316<\/strong>\uff1aConsumeQueue\u5c0f\u800c\u56fa\u5b9a\uff0c\u53ef\u5168\u91cf\u7f13\u5b58\u81f3\u5185\u5b58\uff0c\u8bfb\u64cd\u4f5c\u53d8\u4e3a\u201c\u5185\u5b58\u5bfb\u5740 + CommitLog\u987a\u5e8f\/\u968f\u673a\u8bfb\u201d\u3002\u5728PageCache\u547d\u4e2d\u7387\u9ad8\u65f6\u8868\u73b0\u4f18\u5f02\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\u6269\u5c55\u6027\u4e0e\u6210\u672c<\/strong><\/td>\n<td><strong>\u6587\u4ef6\u53e5\u67c4\uff08inode\uff09\u5f00\u9500\u5927<\/strong>\uff1a\u6bcf\u4e2a\u5206\u533a\u90fd\u662f\u72ec\u7acb\u76ee\u5f55\u548c\u6587\u4ef6\uff0c\u6d77\u91cf\u5206\u533a\u65f6\u8fd0\u7ef4\u6210\u672c\u9ad8\u3002<\/td>\n<td><strong>\u5b58\u50a8\u6210\u672c\u4e0e\u6548\u7387\u66f4\u4f18<\/strong>\uff1a\u591aTopic\u5171\u4eabCommitLog\uff0c\u6587\u4ef6\u6570\u5c11\uff0c<strong>\u7279\u522b\u9002\u5408\u4e2d\u5c0f\u6d88\u606f\u4f53\u3001\u591aTopic\u7684\u573a\u666f<\/strong>\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\u5178\u578b\u573a\u666f<\/strong><\/td>\n<td><strong>\u65e5\u5fd7\u6d41\u3001\u6307\u6807\u76d1\u63a7\u3001\u5b9e\u65f6\u6d41\u5904\u7406<\/strong>\uff1a\u4f5c\u4e3a\u5927\u6570\u636e\u7ba1\u9053\uff0c\u4e0eFlink\/Spark\u751f\u6001\u65e0\u7f1d\u96c6\u6210\u3002<\/td>\n<td><strong>\u7535\u5546\u4ea4\u6613\u3001\u91d1\u878d\u4e1a\u52a1\u3001\u5f02\u6b65\u89e3\u8026<\/strong>\uff1a\u9700\u8981\u4e25\u683c\u987a\u5e8f\u3001\u4e8b\u52a1\u4fdd\u969c\u3001\u4e1a\u52a1\u67e5\u8be2\u7684\u5728\u7ebf\u4e1a\u52a1\u573a\u666f\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u603b\u800c\u8a00\u4e4b\uff0cKafka\u50cf\u4e00\u4e2a\u8bbe\u8ba1\u7cbe\u826f\u7684<strong>\u9ad8\u901f\u516c\u8def\u7cfb\u7edf\uff0c<\/strong> \u6838\u5fc3\u76ee\u6807\u662f\u8ba9\u6570\u636e\u8f66\u8f86\uff08\u6d88\u606f\uff09\u80fd\u591f\u9ad8\u541e\u5410\u3001\u4f4e\u5ef6\u8fdf\u5730\u6301\u7eed\u6d41\u52a8\uff0c\u5e76\u65b9\u4fbf\u5730\u5f15\u5411\u5404\u4e2a\u5904\u7406\u5de5\u5382\uff08\u6d41\u8ba1\u7b97\uff09\u3002\u800cRocketMQ\u5219\u50cf\u4e00\u4e2a\u9ad8\u5ea6\u53ef\u9760\u7684<strong>\u5feb\u9012\u7f51\u7edc\uff0c<\/strong> \u4e0d\u4ec5\u786e\u4fdd\u5305\u88f9\uff08\u6d88\u606f\uff09\u51c6\u786e\u9001\u8fbe\uff0c\u8fd8\u63d0\u4f9b\u9884\u7ea6\u914d\u9001\uff08\u5b9a\u65f6\uff09\u3001\u7b7e\u6536\u786e\u8ba4\uff08\u4e8b\u52a1\uff09\u3001\u5f02\u5e38\u91cd\u6295\uff08\u91cd\u8bd5\uff09\u7b49\u4e00\u7cfb\u5217\u670d\u52a1\u4e8e\u4e1a\u52a1\u903b\u8f91\u7684\u589e\u503c\u529f\u80fd\u3002<\/p>\n<h3>RocketMQ\u5bf9\u4e8e\u968f\u673a\u8bfb\u53d6\u7684\u4f18\u5316<\/h3>\n<p>RocketMQ\u5728\u6d88\u8d39\u65f6\u5019\u7684\u6d41\u7a0b<\/p>\n<pre><code>\u6d88\u8d39\u8005\u8bf7\u6c42\u00a0\u2192\u00a0ConsumeQueue\uff08\u5185\u5b58\/\u987a\u5e8f\uff09\u83b7\u53d6commitlog\u4e0a\u7684\u7269\u7406\u504f\u79fb\u91cf \u2192 \u6839\u636e\u7269\u7406\u504f\u79fb\u91cf\u5b9a\u4f4dCommitLog\uff08\u78c1\u76d8\/\u968f\u673a\uff09\u00a0\u2192\u00a0\u8fd4\u56de\u6d88\u606f<\/code><\/pre>\n<p>\u4eceConsumeQueue\u83b7\u53d6\u5230\u6d88\u606f\u5728commitlog\u4e2d\u7684\u504f\u79fb\u91cf\u7684\u65f6\u5019\uff0c\u56de\u67e5\u65f6\u5019\u53ef\u80fd\u4ea7\u751f\u968f\u673aIO<\/p>\n<ol>\n<li><strong>\u7b2c\u4e00\u6b21\u968f\u673aIO\uff1a<\/strong> \u6839\u636eConsumeQueue\u4e2d\u7684\u7269\u7406\u504f\u79fb\u91cf\uff0c\u5728CommitLog\u4e2d\u5b9a\u4f4d\u6d88\u606f\u4f4d\u7f6e<\/li>\n<li><strong>\u53ef\u80fd\u7684\u8fde\u7eed\u968f\u673aIO\uff1a<\/strong> \u5982\u679c\u4e00\u6b21\u62c9\u53d6\u591a\u6761\u6d88\u606f\uff0c\u8fd9\u4e9b\u6d88\u606f\u5728CommitLog\u4e2d\u53ef\u80fd\u7269\u7406\u4e0d\u8fde\u7eed<\/li>\n<\/ol>\n<p>\u4e3a\u4e86\u4fdd\u8bc1RocketMQ\u7684\u9ad8\u6027\u80fd\uff0c\u91c7\u7528\u4e00\u4e9b\u4f18\u5316\u63aa\u65bd\uff0c\u5c3d\u91cf\u907f\u514d\u968f\u673aIO<\/p>\n<p><strong>1. ConsumeQueue\u7684\u5185\u5b58\u6620\u5c04\u4f18\u5316<\/strong><\/p>\n<p>\u5b9e\u9645\u4e0a\uff0cRocketMQ\u5c06ConsumeQueue\u6620\u5c04\u5230\u5185\u5b58,\u6bcf\u4e2aConsumeQueue\u7ea65.72MB\uff0c\u53ef\u5b8c\u5168\u653e\u5165PageCache,\u8bfb\u7d22\u5f15\u64cd\u4f5c\u51e0\u4e4e\u662f\u5185\u5b58\u64cd\u4f5c\u3002<\/p>\n<pre><code>public\u00a0class\u00a0ConsumeQueue\u00a0{\n\u00a0 \u00a0 private MappedFile mappedFile; \u00a0\/\/\u00a0\u5185\u5b58\u6620\u5c04\u6587\u4ef6\n\u00a0 \u00a0 \/\/\u00a020\u5b57\u8282\u6bcf\u6761\uff1a8(offset) +\u00a04(size) +\u00a08(tagHashCode)\n}<\/code><\/pre>\n<p><strong>2. PageCache\u7684\u5145\u5206\u5229\u7528<\/strong><\/p>\n<p>Linux PageCache\u5de5\u4f5c\u6d41\u7a0b\uff1a\u00a0<\/p>\n<ol>\n<li>\u6d88\u606f\u5199\u5165CommitLog \u2192 \u8fdb\u5165PageCache<\/li>\n<li>\u6d88\u8d39\u8005\u8bfb\u53d6 \u2192 \u4f18\u5148\u4ecePageCache\u83b7\u53d6<\/li>\n<li>\u5982\u679cPageCache\u547d\u4e2d\uff1a\u5185\u5b58\u901f\u5ea6\uff08\u2248100ns\uff09<\/li>\n<li>\u5982\u679cPageCache\u672a\u547d\u4e2d\uff1a\u78c1\u76d8\u968f\u673a\u8bfb\u53d6\uff08\u224810ms\uff09<\/li>\n<\/ol>\n<p><strong>3. \u6279\u91cf\u8bfb\u53d6\u4f18\u5316<\/strong><\/p>\n<pre><code>\/\/ DefaultMessageStore.java\npublic\u00a0GetMessageResult\u00a0getMessage(...)\u00a0{\n\u00a0 \u00a0\u00a0\/\/ \u4e00\u6b21\u8bfb\u53d6\u591a\u6761\u6d88\u606f\uff08\u9ed8\u8ba4\u6700\u591a32\u6761\uff09\n\u00a0 \u00a0\u00a0\/\/ \u5373\u4f7f\u8fd9\u4e9b\u6d88\u606f\u7269\u7406\u4e0d\u8fde\u7eed\uff0c\u901a\u8fc7\u6279\u91cf\u8bfb\u53d6\u51cf\u5c11IO\u6b21\u6570\n\u00a0 \u00a0\u00a0for\u00a0(int\u00a0i =\u00a00; i &lt; maxMsgNums; i++) {\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u4f7f\u7528\u540c\u4e00\u4e2a\u6587\u4ef6channel\u6279\u91cf\u8bfb\u53d6\n\u00a0 \u00a0 \u00a0 \u00a0 readMessage(ctx, msgId, consumerGroup);\n\u00a0 \u00a0 }\n}<\/code><\/pre>\n<p><strong>4. \u8bfb\u53d6\u987a\u5e8f\u6027\u7684\u4fdd\u6301<\/strong><\/p>\n<p>\u867d\u7136CommitLog\u4e2d\u4e0d\u540cTopic\u7684\u6d88\u606f\u662f\u968f\u673a\u5b58\u653e\u7684\uff0c\u4f46\u540c\u4e00\u4e2aQueue\u7684\u6d88\u606f\u5728CommitLog\u4e2d\u662f\u57fa\u672c\u8fde\u7eed\u7684\uff1a<\/p>\n<pre><code>Queue1: | Msg1 | Msg3 | Msg5 | ... | \u5728ConsumeQueue\u4e2d\u8fde\u7eed\n\u00a0 \u00a0 \u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0\u2193 \u00a0 \u00a0 \u00a0\u2193\nCommitLog: | Msg1 | Msg2(T2) | Msg3 | Msg4(T3) | Msg5 |\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2191_________________________\u2191\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u7269\u7406\u4e0a\u76f8\u5bf9\u8fde\u7eed\uff0c\u51cf\u5c11\u78c1\u5934\u5bfb\u9053<\/code><\/pre>\n<h3>\u9ad8\u53ef\u7528\u8bbe\u8ba1\uff1a\u53cc\u8f68\u5e76\u884c\u7684\u53ef\u9760\u6027\u67b6\u6784<\/h3>\n<p><strong>\u4e3b\u4ece\u67b6\u6784\uff08Master-Slave\uff09<\/strong><\/p>\n<p><strong>\u7ecf\u5178\u4e3b\u4ece\u6a21\u5f0f\uff1a<\/strong> RocketMQ\u65e9\u671f\u91c7\u7528Master-Slave\u67b6\u6784\uff0cMaster\u5904\u7406\u6240\u6709\u8bfb\u5199\u8bf7\u6c42\uff0cSlave\u4ec5\u4f5c\u4e3a\u70ed\u5907\u4efd\u3002\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0c<strong>\u6545\u969c\u5207\u6362\u4f9d\u8d56\u4eba\u5de5\u5e72\u9884\u6216\u534a\u81ea\u52a8\u811a\u672c\uff0c<\/strong> \u6062\u590d\u65f6\u95f4\u901a\u5e38\u5728\u5206\u949f\u7ea7\u522b\u3002<\/p>\n<p><strong>Dledger\u9ad8\u53ef\u7528\u96c6\u7fa4\uff1a<\/strong> RocketMQ 4.5\u5f15\u5165\u7684Dledger\u57fa\u4e8eRaft\u534f\u8bae\u5b9e\u73b0<strong>\u771f\u6b63\u7684\u4e3b\u4ece\u81ea\u52a8\u5207\u6362\u3002<\/strong> \u5f53Master\u6545\u969c\u65f6\uff0c\u96c6\u7fa4\u80fd\u5728\u79d2\u7ea7\uff08\u901a\u5e382-10\u79d2\uff09\u5185\u81ea\u52a8\u9009\u4e3e\u65b0Leader\uff0c\u671f\u95f4\u6d88\u606f\u4ecd\u53ef\u5199\u5165\uff08\u5199\u5165\u8bf7\u6c42\u4f1a\u963b\u585e\u81f3\u65b0Leader\u9009\u51fa\uff09\u3002<\/p>\n<p><strong>\u591a\u526f\u672c\u673a\u5236\uff1a<\/strong> \u73b0\u4ee3\u90e8\u7f72\u4e2d\uff0c\u5efa\u8bae\u91c7\u7528<strong>2\u4e3b2\u4ece\u62163\u4e3b3\u4ece<\/strong>\u67b6\u6784\u3002\u4f8b\u5982\u5728\u963f\u91cc\u4e91\u4e0a\uff0c\u6bcf\u4e2aBroker\u7ec4\u5305\u542b1\u4e2aMaster\u548c2\u4e2aSlave\uff0c\u5f62\u6210<strong>\u8de8\u53ef\u7528\u533a\u7684\u4e09\u526f\u672c\uff0c<\/strong> \u5355\u673a\u623f\u6545\u969c\u4e0d\u5f71\u54cd\u670d\u52a1\u53ef\u7528\u6027\u3002<\/p>\n<p><strong>\u540c\u6b65\/\u5f02\u6b65\u590d\u5236<\/strong><\/p>\n<p>\u540c\u6b65\u590d\u5236\u4fdd\u8bc1\u5f3a\u4e00\u81f4\uff08\u6d88\u606f\u4e0d\u4e22\u5931\uff09\uff0c\u5f02\u6b65\u590d\u5236\u8ffd\u6c42\u66f4\u9ad8\u6027\u80fd\u3002<\/p>\n<pre><code>\/\/ Broker\u914d\u7f6e\u793a\u4f8b\nbrokerRole =\u00a0SYNC_MASTER\n\/\/ \u751f\u4ea7\u8005\u53d1\u9001\u6d88\u606f\u540e\uff0c\u5fc5\u987b\u7b49\u5f85\u81f3\u5c11\u4e00\u4e2aSlave\u786e\u8ba4\n\/\/ \u786e\u4fdd\u5373\u4f7fMaster\u5b95\u673a\uff0c\u6d88\u606f\u4e5f\u4e0d\u4f1a\u4e22\u5931<\/code><\/pre>\n<ul>\n<li>\u5f3a\u4e00\u81f4\u6027\u4fdd\u8bc1\uff1a\u6d88\u606f\u5199\u5165Master\u540e\uff0c\u540c\u6b65\u590d\u5236\u5230Slave\u624d\u8fd4\u56de\u6210\u529f<\/li>\n<li>\u6027\u80fd\u4ee3\u4ef7\uff1a\u5ef6\u8fdf\u589e\u52a0\u7ea630-50%\uff0cTPS\u4e0b\u964d\u7ea620-40%<\/li>\n<li>\u9002\u7528\u573a\u666f\uff1a\u91d1\u878d\u4ea4\u6613\u3001\u8d44\u91d1\u53d8\u52a8\u7b49\u5bf9\u6570\u636e\u4e00\u81f4\u6027\u8981\u6c42\u6781\u9ad8\u7684\u4e1a\u52a1<\/li>\n<\/ul>\n<p><strong>\u540c\u6b65\/\u5f02\u6b65\u5237\u76d8<\/strong><\/p>\n<p>\u540c\u6b65\u5237\u76d8\u4fdd\u8bc1\u6d88\u606f\u6301\u4e45\u5316\u4e0d\u4e22\u5931\uff0c\u5f02\u6b65\u5237\u76d8\u63d0\u5347\u541e\u5410\u3002<\/p>\n<pre><code>brokerRole =\u00a0ASYNC_MASTER\n\/\/ \u6d88\u606f\u5199\u5165Master\u5373\u8fd4\u56de\u6210\u529f\uff0cSlave\u5f02\u6b65\u590d\u5236\n\/\/ \u5b58\u5728\u6781\u77ed\u65f6\u95f4\u7684\u6570\u636e\u4e22\u5931\u98ce\u9669<\/code><\/pre>\n<ul>\n<li><strong>\u9ad8\u6027\u80fd\u6a21\u5f0f\uff1a<\/strong> \u5ef6\u8fdf\u964d\u4f4e\uff0c\u541e\u5410\u91cf\u63a5\u8fd1\u5355\u8282\u70b9\u6027\u80fd<\/li>\n<li><strong>\u98ce\u9669\u7a97\u53e3\uff1a<\/strong> Master\u5b95\u673a\u4e14\u6570\u636e\u672a\u540c\u6b65\u65f6\uff0c\u6700\u8fd1\u51e0\u79d2\u6d88\u606f\u53ef\u80fd\u4e22\u5931<\/li>\n<li><strong>\u9002\u7528\u573a\u666f\uff1a<\/strong> \u65e5\u5fd7\u6536\u96c6\u3001\u76d1\u63a7\u6570\u636e\u3001\u53ef\u5bb9\u5fcd\u5fae\u91cf\u4e22\u5931\u7684\u4e1a\u52a1\u6d88\u606f<\/li>\n<\/ul>\n<h3>\u5237\u76d8\u7b56\u7565\u7684\u5de5\u7a0b\u4f18\u5316<\/h3>\n<p><strong>\u540c\u6b65\u5237\u76d8\uff08SYNC_FLUSH\uff09<\/strong><\/p>\n<pre><code>\u751f\u4ea7\u8005 \u2192 Broker\u5185\u5b58 \u2192 \u78c1\u76d8\u5f3a\u5236\u5237\u76d8 \u2192 \u8fd4\u56de\u6210\u529f<\/code><\/pre>\n<ul>\n<li><strong>\u96f6\u6570\u636e\u4e22\u5931\uff1a<\/strong> \u5373\u4f7f\u673a\u5668\u6389\u7535\uff0c\u6d88\u606f\u4e5f\u5df2\u6301\u4e45\u5316\u5230\u78c1\u76d8<\/li>\n<li><strong>\u6027\u80fd\u74f6\u9888\uff1a<\/strong> \u6bcf\u6b21\u5199\u5165\u90fd\u89e6\u53d1\u78c1\u76d8IO\uff0c\u673a\u68b0\u786c\u76d8\u4e0bTPS\u901a\u5e38&lt;1000<\/li>\n<li><strong>\u4f18\u5316\u624b\u6bb5\uff1a<\/strong> \u4f7f\u7528SSD\u786c\u76d8\u53ef\u5927\u5e45\u63d0\u5347\u6027\u80fd<\/li>\n<\/ul>\n<p><strong>\u5f02\u6b65\u5237\u76d8\uff08ASYNC_FLUSH\uff09<\/strong><\/p>\n<pre><code>\u751f\u4ea7\u8005 \u2192 Broker\u5185\u5b58 \u2192 \u7acb\u5373\u8fd4\u56de\u6210\u529f \u2192 \u5f02\u6b65\u6279\u91cf\u5237\u76d8<\/code><\/pre>\n<ul>\n<li><strong>\u9ad8\u6027\u80fd\u9009\u62e9\uff1a<\/strong> \u4f9d\u8d56PageCache\uff0cSSD\u4e0bTPS\u53ef\u8fbe\u6570\u4e07\u81f3\u6570\u5341\u4e07<\/li>\n<li><strong>\u53ef\u9760\u6027\u4f9d\u8d56\uff1a<\/strong> \u4f9d\u8d56\u64cd\u4f5c\u7cfb\u7edf\u7684\u5237\u76d8\u673a\u5236\uff08\u901a\u5e385\u79d2\u5237\u76d8\u4e00\u6b21\uff09<\/li>\n<li><strong>\u914d\u7f6e\u8c03\u4f18\uff1a<\/strong><\/li>\n<\/ul>\n<pre><code># \u8c03\u6574\u5237\u76d8\u53c2\u6570\nflushCommitLogLeastPages\u00a0=\u00a04\u00a0 \u00a0\u00a0# \u81f3\u5c114\u9875\uff0816KB\uff09\u624d\u5237\u76d8\nflushCommitLogThoroughInterval\u00a0=\u00a010000\u00a0\u00a0# 10\u79d2\u5f3a\u5236\u5237\u76d8\u4e00\u6b21<\/code><\/pre>\n<h2>\u56db\u3001Producer\u4e0eConsumer\uff1a\u9ad8\u6548\u7684\u751f\u4ea7\u4e0e\u6d88\u8d39\u6a21\u578b<\/h2>\n<h3>Producer<\/h3>\n<p><strong>\u6d88\u606f\u8def\u7531\u7b56\u7565\uff1a<\/strong><\/p>\n<pre><code>\/\/ \u5185\u7f6e\u591a\u79cd\u961f\u5217\u9009\u62e9\u7b97\u6cd5\nDefaultMQProducer\u00a0producer =\u00a0new\u00a0DefaultMQProducer(&quot;ProducerGroup&quot;);\n\/\/ 1. \u8f6e\u8be2\uff08\u9ed8\u8ba4\uff09\uff1a\u5747\u5300\u5206\u5e03\u5230\u6240\u6709\u961f\u5217\n\/\/ 2. \u54c8\u5e0c\uff1a\u76f8\u540cKey\u7684\u6d88\u606f\u8def\u7531\u5230\u540c\u4e00\u961f\u5217\uff0c\u4fdd\u8bc1\u5c40\u90e8\u987a\u5e8f\n\/\/ 3. \u673a\u623f\u5c31\u8fd1\uff1a\u4f18\u5148\u9009\u62e9\u540c\u673a\u623f\u7684Broker\nproducer.send(msg,\u00a0new\u00a0MessageQueueSelector() {\n\u00a0 \u00a0\u00a0@Override\n\u00a0 \u00a0\u00a0public\u00a0MessageQueue\u00a0select(List&lt;MessageQueue&gt; mqs,\u00a0Message\u00a0msg,\u00a0Object\u00a0arg) {\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u81ea\u5b9a\u4e49\u8def\u7531\u903b\u8f91\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0return\u00a0mqs.get(arg.hashCode() % mqs.size());\n\u00a0 \u00a0 }\n});<\/code><\/pre>\n<p><strong>\u53d1\u9001\u6a21\u5f0f\u5bf9\u6bd4\uff1a<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u6a21\u5f0f<\/th>\n<th>\u7279\u70b9<\/th>\n<th>\u6027\u80fd<\/th>\n<th>\u9002\u7528\u573a\u666f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\u540c\u6b65\u53d1\u9001<\/strong><\/td>\n<td>\u963b\u585e\u7b49\u5f85Broker\u54cd\u5e94<\/td>\n<td>TPS\u7ea65000-20000<\/td>\n<td>\u91cd\u8981\u4e1a\u52a1\u6d88\u606f\uff0c\u9700\u7acb\u5373\u77e5\u9053\u53d1\u9001\u7ed3\u679c<\/td>\n<\/tr>\n<tr>\n<td><strong>\u5f02\u6b65\u53d1\u9001<\/strong><\/td>\n<td>\u56de\u8c03\u901a\u77e5\u7ed3\u679c<\/td>\n<td>TPS\u53ef\u8fbe50000+<\/td>\n<td>\u9ad8\u5e76\u53d1\u573a\u666f\uff0c\u5982\u65e5\u5fd7\u3001\u76d1\u63a7\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td><strong>\u5355\u5411\u53d1\u9001<\/strong><\/td>\n<td>\u53d1\u9001\u540e\u4e0d\u7b49\u5f85<\/td>\n<td>TPS\u6700\u9ad8\uff08100000+\uff09<\/td>\n<td>\u53ef\u5bb9\u5fcd\u5c11\u91cf\u4e22\u5931\u7684\u975e\u5173\u952e\u6570\u636e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u5931\u8d25\u91cd\u8bd5\u4e0e\u7194\u65ad\uff1a<\/strong><\/p>\n<ul>\n<li><strong>\u667a\u80fd\u91cd\u8bd5\uff1a<\/strong> \u53d1\u9001\u5931\u8d25\u65f6\u81ea\u52a8\u91cd\u8bd5\uff08\u9ed8\u8ba42\u6b21\uff09\uff0c\u53ef\u914d\u7f6e\u9000\u907f\u7b56\u7565<\/li>\n<li><strong>\u6545\u969c\u89c4\u907f\uff1a<\/strong> \u81ea\u52a8\u68c0\u6d4bBroker\u53ef\u7528\u6027\uff0c\u6545\u969c\u671f\u95f4\u8def\u7531\u5230\u5065\u5eb7\u8282\u70b9<\/li>\n<li><strong>\u6162\u8bf7\u6c42\u7194\u65ad\uff1a<\/strong> \u7edf\u8ba1\u53d1\u9001\u8017\u65f6\uff0c\u81ea\u52a8\u9694\u79bb\u54cd\u5e94\u6162\u7684Broker<\/li>\n<\/ul>\n<h3>Consumer<\/h3>\n<p><strong>\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\uff1a<\/strong><\/p>\n<pre><code>\/\/ \u96c6\u7fa4\u6a21\u5f0f\uff1a\u540c\u4e00ConsumerGroup\u5185\u6d88\u8d39\u8005\u5747\u5206\u961f\u5217\nconsumer.setMessageModel(MessageModel.CLUSTERING);\n\/\/ \u5e7f\u64ad\u6a21\u5f0f\uff1a\u6bcf\u4e2a\u6d88\u8d39\u8005\u6d88\u8d39\u5168\u91cf\u961f\u5217\nconsumer.setMessageModel(MessageModel.BROADCASTING);<\/code><\/pre>\n<p><strong>\u6d88\u8d39\u8fdb\u5ea6\u7ba1\u7406\uff1a<\/strong><\/p>\n<p><strong>Broker\u6258\u7ba1\uff1a<\/strong> \u9ed8\u8ba4\u65b9\u5f0f\uff0c\u6d88\u8d39\u8fdb\u5ea6\u5b58\u50a8\u5728Broker<\/p>\n<p><strong>\u672c\u5730\u7ef4\u62a4\uff1a<\/strong> \u67d0\u4e9b\u573a\u666f\u4e0b\u53ef\u81ea\u4e3b\u7ba1\u7406offset\uff08\u5982\u6279\u91cf\u5904\u7406\uff09<\/p>\n<p><strong>\u91cd\u7f6e\u7b56\u7565\uff1a<\/strong><\/p>\n<pre><code>\/\/ \u652f\u6301\u591a\u79cd\u6d88\u8d39\u8d77\u70b9\nconsumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET); \u00a0\/\/ \u4ece\u6700\u540e\nconsumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);\u00a0\/\/ \u4ece\u5934\nconsumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_TIMESTAMP); \u00a0 \u00a0\/\/ \u4ece\u65f6\u95f4\u70b9<\/code><\/pre>\n<p><strong>\u5e76\u53d1\u63a7\u5236\u4f18\u5316\uff1a<\/strong><\/p>\n<pre><code>\/\/ \u5173\u952e\u5e76\u53d1\u53c2\u6570\nconsumer.setConsumeThreadMin(20); \u00a0 \u00a0\u00a0\/\/ \u6700\u5c0f\u6d88\u8d39\u7ebf\u7a0b\u6570\nconsumer.setConsumeThreadMax(64); \u00a0 \u00a0\u00a0\/\/ \u6700\u5927\u6d88\u8d39\u7ebf\u7a0b\u6570\nconsumer.setPullBatchSize(32); \u00a0 \u00a0 \u00a0 \u00a0\/\/ \u6bcf\u6b21\u62c9\u53d6\u6d88\u606f\u6570\nconsumer.setConsumeMessageBatchMaxSize(1);\u00a0\/\/ \u6279\u91cf\u6d88\u8d39\u5927\u5c0f\n\/\/ \u6d41\u63a7\u673a\u5236\nconsumer.setPullThresholdForQueue(1000); \u00a0\/\/ \u961f\u5217\u5806\u79ef\u9608\u503c\nconsumer.setPullInterval(0); \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/ \u62c9\u53d6\u95f4\u9694\uff080\u4e3a\u957f\u8f6e\u8be2\uff09<\/code><\/pre>\n<h2>\u4e94\u3001\u6838\u5fc3\u6d41\u7a0b\u4e0e\u7279\u6027\u80cc\u540e\u7684\u67b6\u6784\u652f\u6491<\/h2>\n<p>1 <strong>.\u987a\u5e8f\u6d88\u606f\u5982\u4f55\u4fdd\u8bc1\uff1f<\/strong><\/p>\n<p><strong>\u5168\u5c40\u987a\u5e8f\uff1a<\/strong> \u5355Topic\u5355\u961f\u5217\uff08\u727a\u7272\u5e76\u53d1\uff09\u3002<\/p>\n<p><strong>\u5206\u533a\u987a\u5e8f\uff1a<\/strong> \u901a\u8fc7<strong>MessageQueue\u9009\u62e9\u5668<\/strong>\u786e\u4fdd\u540c\u4e00\u4e1a\u52a1\u952e\uff08\u5982\u8ba2\u5355ID\uff09\u7684\u6d88\u606f\u53d1\u5f80\u540c\u4e00\u961f\u5217\uff0cConsumer\u7aef\u6309\u961f\u5217\u987a\u5e8f\u6d88\u8d39\u3002<\/p>\n<p><strong>2.\u4e8b\u52a1\u6d88\u606f\u7684\u4e24\u9636\u6bb5\u63d0\u4ea4<\/strong><\/p>\n<p><strong>\u6d41\u7a0b\u8be6\u89e3\uff1a<\/strong> Half Message -&gt; \u6267\u884c\u672c\u5730\u4e8b\u52a1 -&gt; Commit\/Rollback\u3002<\/p>\n<p><strong>\u67b6\u6784\u652f\u6491\uff1a<\/strong> Op\u6d88\u606f\u56de\u67e5\u673a\u5236\uff0c\u89e3\u51b3\u5206\u5e03\u5f0f\u4e8b\u52a1\u7684\u6700\u7ec8\u4e00\u81f4\u6027\uff0c\u662f\u67b6\u6784\u8bbe\u8ba1\u4e2d\u201c\u72b6\u6001\u53ef\u56de\u6eaf\u201d\u601d\u60f3\u7684\u4f53\u73b0\u3002<\/p>\n<p><strong>3.\u5ef6\u65f6\u6d88\u606f\u7684\u5b9e\u73b0\u5965\u79d8<\/strong><\/p>\n<p><strong>\u5e76\u975e\u771f\u6b63\u5ef6\u8fdf\u6295\u9012\uff1a<\/strong> \u4e3a\u4e0d\u540c\u5ef6\u8fdf\u7ea7\u522b\u9884\u8bbe<strong>\u72ec\u7acb\u7684SCHEDULE_TOPIC\uff0c<\/strong> \u5b9a\u65f6\u4efb\u52a1\u626b\u63cf\u5230\u671f\u540e\u6295\u9012\u81f3\u771f\u5b9eTopic\u3002<\/p>\n<p><strong>\u8bbe\u8ba1\u6743\u8861\uff1a<\/strong> \u4ee5\u5b58\u50a8\u548c\u8ba1\u7b97\u6362\u53d6\u529f\u80fd\u7684\u7075\u6d3b\u4e0e\u53ef\u9760\u3002<\/p>\n<h2>\u516d\u3001\u5176\u4ed6\u6027\u80fd\u4f18\u5316\u5173\u952e\u6280\u672f\u70b9<\/h2>\n<ol>\n<li><strong>\u96f6\u62f7\u8d1d\uff08Zero-copy\uff09\uff1a<\/strong> \u901a\u8fc7sendfile\u6216mmap+write\u65b9\u5f0f\uff0c\u51cf\u5c11\u5185\u6838\u6001\u4e0e\u7528\u6237\u6001\u95f4\u6570\u636e\u62f7\u8d1d\uff0c\u5927\u5e45\u63d0\u5347\u7f51\u7edc\u53d1\u9001\u4e0e\u6587\u4ef6\u8bfb\u5199\u6548\u7387\u3002<\/li>\n<li><strong>\u5806\u5916\u5185\u5b58\u4e0e\u5185\u5b58\u6c60\uff1a<\/strong> \u907f\u514dJVM GC\u5bf9\u5927\u6570\u636e\u5757\u5904\u7406\u7684\u5f71\u54cd\uff0c\u5b9e\u73b0\u9ad8\u6548\u7684\u5185\u5b58\u7ba1\u7406\u3002<\/li>\n<li><strong>\u6587\u4ef6\u9884\u70ed\uff1a<\/strong> \u542f\u52a8\u65f6\u5c06\u5b58\u50a8\u6587\u4ef6\u6620\u5c04\u5230\u5185\u5b58\u5e76\u5199\u5165\u201c\u5047\u6570\u636e\u201d\uff0c\u907f\u514d\u8fd0\u884c\u65f6\u7f3a\u9875\u4e2d\u65ad\u3002<\/li>\n<\/ol>\n<h2>\u4e03\u3001\u603b\u7ed3\uff1aRocketMQ\u67b6\u6784\u8bbe\u8ba1\u7684\u542f\u793a<\/h2>\n<p>RocketMQ\u7684\u67b6\u6784\u8bbe\u8ba1\uff0c\u5c24\u5176\u662f\u5176\u5728\u7b80\u6d01\u6027\u3001\u9ad8\u6027\u80fd\u548c\u4e91\u539f\u751f\u6f14\u8fdb\u65b9\u9762\u7684\u5e73\u8861\uff0c\u4e3a\u6784\u5efa\u73b0\u4ee3\u5206\u5e03\u5f0f\u7cfb\u7edf\u63d0\u4f9b\u4e86\u8bb8\u591a\u5b9d\u8d35\u542f\u793a\u3002<\/p>\n<ol>\n<li><strong>\u5728\u7b80\u5355\u4e0e\u5b8c\u5907\u95f4\u6743\u8861\uff1a<\/strong> RocketMQ\u6ca1\u6709\u91c7\u7528\u5f3a\u4e00\u81f4\u6027\u7684ZooKeeper\uff0c\u800c\u662f\u81ea\u7814\u4e86\u6781\u5176\u7b80\u5355\u7684NameServer\u3002\u8fd9\u8bf4\u660e\u5728\u975e\u6838\u5fc3\u8def\u5f84\u4e0a\uff0c\u727a\u7272\u4e00\u5b9a\u7684\u529f\u80fd\u5b8c\u5907\u6027\u6765\u6362\u53d6\u7b80\u5355\u6027\u548c\u9ad8\u53ef\u7528\u6027\uff0c\u53ef\u80fd\u4e5f\u662f\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\u3002<\/li>\n<li><strong>\u4ee5\u5199\u5b9a\u5b58\u50a8\uff0c\u4ee5\u8bfb\u4f18\u67e5\u8be2\uff1a<\/strong> \u5176\u5b58\u50a8\u67b6\u6784\u662f\u5178\u578b\u7684\u5199\u4f18\u5316\u8bbe\u8ba1\u3002\u6240\u6709\u6d88\u606f\u987a\u5e8f\u8ffd\u52a0\u5199\u5165\uff0c\u4fdd\u8bc1\u4e86\u6700\u9ad8\u7684\u5199\u5165\u6027\u80fd\u3002\u800c\u9488\u5bf9\u6d88\u8d39\u548c\u67e5\u8be2\u8fd9\u4e24\u79cd\u4e3b\u8981\u7684\u201c\u8bfb\u201d\u573a\u666f\uff0c\u5219\u5206\u522b\u901a\u8fc7\u5f02\u6b65\u6784\u5efa\u7d22\u5f15\u6570\u636e\u7ed3\u6784\uff08ConsumeQueue\u548cIndexFile\uff09\u6765\u4f18\u5316\u3002<\/li>\n<\/ol>\n<h2>\u516b\u3001\u53c2\u8003\u8d44\u6599<\/h2>\n<ul>\n<li><a href=\"https:\/\/segmentfault.com\/a\/\u4e3a\u4ec0\u4e48\u9009\u62e9RocketMQ\" title=\"| RocketMQ\u00a0https:\/\/rocketmq.apache.org\/zh\/docs\/\" target=\"_blank\" rel=\"noopener noreferrer\">RocketMQ\u5b98\u65b9\u6587\u6863<\/a><\/li>\n<li><a href=\"https:\/\/segmentfault.com\/a\/Apache\" title=\"RocketMQ \u539f\u7406\u548c\u67b6\u6784\u00a0https:\/\/rocketmq-learning.com\/course\/baseLearn\/rocketmq_learning-framework\/?spm=5176.29160081.0.0.a2807833VzCxtS&amp;source=home\" target=\"_blank\" rel=\"noopener noreferrer\">RocketMQ\u4e2d\u6587\u793e\u533a<\/a><\/li>\n<\/ul>\n<h3>\u5f80\u671f\u56de\u987e<\/h3>\n<p>1.PAG\u5728\u5f97\u7269\u793e\u533aS\u7ea7\u6d3b\u52a8\u7684\u843d\u5730<\/p>\n<p>2.Ant Design 6.0 \u5c1d\u9c9c\uff1a\u4e0a\u624b\u73b0\u4ee3\u5316\u7ec4\u4ef6\u5f00\u53d1\uff5c\u5f97\u7269\u6280\u672f\u00a0<\/p>\n<p>3.Java \u8bbe\u8ba1\u6a21\u5f0f\uff1a\u539f\u7406\u3001\u6846\u67b6\u5e94\u7528\u4e0e\u5b9e\u6218\u5168\u89e3\u6790\uff5c\u5f97\u7269\u6280\u672f<\/p>\n<p>4.Go\u8bed\u8a00\u5728\u9ad8\u5e76\u53d1\u9ad8\u53ef\u7528\u7cfb\u7edf\u4e2d\u7684\u5b9e\u8df5\u4e0e\u89e3\u51b3\u65b9\u6848\uff5c\u5f97\u7269\u6280\u672f<\/p>\n<p>5.\u4ece0\u52301\u642d\u5efa\u4e00\u4e2a\u667a\u80fd\u5206\u6790OBS\u57cb\u70b9\u6570\u636e\u7684AI Agent\uff5c\u5f97\u7269\u6280\u672f<\/p>\n<h3>\u6587 \/\u78ca\u5b50<\/h3>\n<p>\u5173\u6ce8\u5f97\u7269\u6280\u672f\uff0c\u6bcf\u5468\u66f4\u65b0\u6280\u672f\u5e72\u8d27<\/p>\n<p>\u8981\u662f\u89c9\u5f97\u6587\u7ae0\u5bf9\u4f60\u6709\u5e2e\u52a9\u7684\u8bdd\uff0c\u6b22\u8fce\u8bc4\u8bba\u8f6c\u53d1\u70b9\u8d5e\uff5e<\/p>\n<p>\u672a\u7ecf\u5f97\u7269\u6280\u672f\u8bb8\u53ef\u4e25\u7981\u8f6c\u8f7d\uff0c\u5426\u5219\u4f9d\u6cd5\u8ffd\u7a76\u6cd5\u5f8b\u8d23\u4efb\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000047512464\">https:\/\/segmentfault.com\/a\/1190000047512464<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u524d\u8a00 \u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u67b6\u6784\u4e2d\uff0c\u6d88\u606f\u961f\u5217\u5982\u540c\u7545\u901a\u7684\u201c\u4fe1\u606f\u795e\u7ecf\u7f51\u7edc\u201d\uff0c\u627f\u62c5\u7740\u89e3\u8026\u3001\u524a\u5cf0\u4e0e\u5f02\u6b65\u901a\u4fe1\u7684\u6838\u5fc3\u4f7f\u547d\u3002\u5728\u4f17\u591a [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10021155","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10021155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10021155"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10021155\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10021155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10021155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10021155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}