{"id":6663,"date":"2025-09-29T12:40:34","date_gmt":"2025-09-29T04:40:34","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=6663"},"modified":"2025-09-29T12:40:42","modified_gmt":"2025-09-29T04:40:42","slug":"mq-%e7%9a%84-10-%e7%a7%8d%e5%9c%ba%e6%99%af","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/%e9%98%9f%e5%88%97\/mq-%e7%9a%84-10-%e7%a7%8d%e5%9c%ba%e6%99%af\/","title":{"rendered":"MQ \u7684 10 \u79cd\u573a\u666f"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001\u4e3a\u4ec0\u4e48\u9700\u8981\u6d88\u606f\u961f\u5217\uff08MQ\uff09\uff1f<\/strong><\/h2>\n\n\n\n<p>\u5728\u6df1\u5165\u5177\u4f53\u573a\u666f\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u6765\u601d\u8003\u4e00\u4e2a\u57fa\u672c\u95ee\u9898\uff1a\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u6d88\u606f\u961f\u5217\uff1f<\/p>\n\n\n\n<p>\u7cfb\u7edf\u95f4\u7684\u76f4\u63a5\u8c03\u7528\uff1a<img decoding=\"async\" class=\"lazyload\"data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/ibJZVicC7nz5jIGEsda6wC9h7xtUCe5VicsBp3CIb6r1YUgdStULZht5SCicLYWO4XEJk0TsaSRplpYoXngT3MuibGA\/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=1\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u56fe\u7247\"><noscript><img decoding=\"async\" src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/ibJZVicC7nz5jIGEsda6wC9h7xtUCe5VicsBp3CIb6r1YUgdStULZht5SCicLYWO4XEJk0TsaSRplpYoXngT3MuibGA\/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=1\" alt=\"\u56fe\u7247\"><\/noscript><\/p>\n\n\n\n<p>\u5f15\u5165\u6d88\u606f\u961f\u5217\u540e\uff1a<img decoding=\"async\" class=\"lazyload\"data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/ibJZVicC7nz5jIGEsda6wC9h7xtUCe5VicsPvEMm76ic5qhhiavE30X9P4NVrTSoKBSlfBjSdFAnpx486EpjxdFyVqA\/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=2\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u56fe\u7247\"><noscript><img decoding=\"async\" src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/ibJZVicC7nz5jIGEsda6wC9h7xtUCe5VicsPvEMm76ic5qhhiavE30X9P4NVrTSoKBSlfBjSdFAnpx486EpjxdFyVqA\/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=2\" alt=\"\u56fe\u7247\"><\/noscript><\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u901a\u8fc710\u4e2a\u5177\u4f53\u573a\u666f\uff0c\u5e26\u5927\u5bb6\u6765\u6df1\u5165\u7406\u89e3MQ\u7684\u4ef7\u503c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u573a\u666f\u4e00\uff1a\u7cfb\u7edf\u89e3\u8026<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u80cc\u666f\u63cf\u8ff0<\/strong><\/h3>\n\n\n\n<p>\u5728\u6211\u65e9\u671f\u53c2\u4e0e\u7684\u4e00\u4e2a\u7535\u5546\u9879\u76ee\u4e2d\uff0c\u8ba2\u5355\u521b\u5efa\u540e\u9700\u8981\u901a\u77e5\u591a\u4e2a\u7cfb\u7edf\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ \u65e9\u671f\u7684\u7d27\u8026\u5408\u8bbe\u8ba1<\/em><br>public&nbsp;class&nbsp;OrderService&nbsp;{<br>&nbsp; &nbsp;&nbsp;private&nbsp;InventoryService inventoryService;<br>&nbsp; &nbsp;&nbsp;private&nbsp;PointsService pointsService;<br>&nbsp; &nbsp;&nbsp;private&nbsp;EmailService emailService;<br>&nbsp; &nbsp;&nbsp;private&nbsp;AnalyticsService analyticsService;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;createOrder(Order order)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 1. \u4fdd\u5b58\u8ba2\u5355<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; orderDao.save(order);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 2. \u8c03\u7528\u5e93\u5b58\u670d\u52a1<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; inventoryService.updateInventory(order);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 3. \u8c03\u7528\u79ef\u5206\u670d\u52a1<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; pointsService.addPoints(order.getUserId(), order.getAmount());<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 4. \u53d1\u9001\u90ae\u4ef6\u901a\u77e5<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; emailService.sendOrderConfirmation(order);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 5. \u8bb0\u5f55\u5206\u6790\u6570\u636e<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; analyticsService.trackOrderCreated(order);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u66f4\u591a\u670d\u52a1...<\/em><br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u79cd\u67b6\u6784\u5b58\u5728\u4e25\u91cd\u95ee\u9898\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7d27\u8026\u5408<\/strong>\uff1a\u8ba2\u5355\u670d\u52a1\u9700\u8981\u77e5\u9053\u6240\u6709\u4e0b\u6e38\u670d\u52a1<\/li>\n\n\n\n<li><strong>\u5355\u70b9\u6545\u969c<\/strong>\uff1a\u4efb\u4f55\u4e00\u4e2a\u4e0b\u6e38\u670d\u52a1\u6302\u6389\u90fd\u4f1a\u5bfc\u81f4\u8ba2\u5355\u521b\u5efa\u5931\u8d25<\/li>\n\n\n\n<li><strong>\u6027\u80fd\u74f6\u9888<\/strong>\uff1a\u540c\u6b65\u8c03\u7528\u5bfc\u81f4\u54cd\u5e94\u65f6\u95f4\u6162<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>MQ\u89e3\u51b3\u65b9\u6848<\/strong><\/h3>\n\n\n\n<p>\u5f15\u5165MQ\u540e\uff0c\u67b6\u6784\u53d8\u4e3a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"742\" height=\"322\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-6664 lazyload\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png 742w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149-300x130.png 300w\" sizes=\"auto, (max-width: 742px) 100vw, 742px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"742\" height=\"322\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png\" alt=\"\" class=\"wp-image-6664\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png 742w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149-300x130.png 300w\" sizes=\"auto, (max-width: 742px) 100vw, 742px\" \/><\/noscript><\/figure>\n\n\n\n<p><strong>\u4ee3\u7801\u5b9e\u73b0<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ \u8ba2\u5355\u670d\u52a1 - \u751f\u4ea7\u8005<\/em><br>@Service<br>public&nbsp;class&nbsp;OrderService&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;RabbitTemplate rabbitTemplate;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;createOrder(Order order)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 1. \u4fdd\u5b58\u8ba2\u5355<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; orderDao.save(order);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 2. \u53d1\u9001\u6d88\u606f\u5230MQ<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; rabbitTemplate.convertAndSend(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"order.exchange\",<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"order.created\",<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;new&nbsp;OrderCreatedEvent(order.getId(), order.getUserId(), order.getAmount())<br>&nbsp; &nbsp; &nbsp; &nbsp; );<br>&nbsp; &nbsp; }<br>}<br><br><em>\/\/ \u5e93\u5b58\u670d\u52a1 - \u6d88\u8d39\u8005<\/em><br>@Component<br>@RabbitListener(queues =&nbsp;\"inventory.queue\")<br>public&nbsp;class&nbsp;InventoryConsumer&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;InventoryService inventoryService;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;@RabbitHandler<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;handleOrderCreated(OrderCreatedEvent event)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; inventoryService.updateInventory(event.getOrderId());<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u6280\u672f\u8981\u70b9<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6d88\u606f\u534f\u8bae\u9009\u62e9<\/strong>\uff1a\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u9009\u62e9RabbitMQ\u3001Kafka\u6216RocketMQ<\/li>\n\n\n\n<li><strong>\u6d88\u606f\u683c\u5f0f<\/strong>\uff1a\u4f7f\u7528JSON\u6216Protobuf\u7b49\u8de8\u8bed\u8a00\u683c\u5f0f<\/li>\n\n\n\n<li><strong>\u9519\u8bef\u5904\u7406<\/strong>\uff1a\u5b9e\u73b0\u91cd\u8bd5\u673a\u5236\u548c\u6b7b\u4fe1\u961f\u5217<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u573a\u666f\u4e8c\uff1a\u5f02\u6b65\u5904\u7406<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u80cc\u666f\u63cf\u8ff0<\/strong><\/h3>\n\n\n\n<p>\u7528\u6237\u4e0a\u4f20\u89c6\u9891\u540e\u9700\u8981\u6267\u884c\u8f6c\u7801\u3001\u751f\u6210\u7f29\u7565\u56fe\u3001\u5185\u5bb9\u5ba1\u6838\u7b49\u8017\u65f6\u64cd\u4f5c\uff0c\u5982\u679c\u540c\u6b65\u5904\u7406\uff0c\u7528\u6237\u9700\u8981\u7b49\u5f85\u5f88\u957f\u65f6\u95f4\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>MQ\u89e3\u51b3\u65b9\u6848<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ \u89c6\u9891\u670d\u52a1 - \u751f\u4ea7\u8005<\/em><br>@Service<br>public&nbsp;class&nbsp;VideoService&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;KafkaTemplate&lt;String, Object&gt; kafkaTemplate;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;public&nbsp;UploadResponse&nbsp;uploadVideo(MultipartFile file, String userId)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 1. \u4fdd\u5b58\u539f\u59cb\u89c6\u9891<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; String videoId = saveOriginalVideo(file);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 2. \u53d1\u9001\u5904\u7406\u6d88\u606f<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; kafkaTemplate.send(\"video-processing\",&nbsp;new&nbsp;VideoProcessingEvent(videoId, userId));<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 3. \u7acb\u5373\u8fd4\u56de\u54cd\u5e94<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;new&nbsp;UploadResponse(videoId,&nbsp;\"upload_success\");<br>&nbsp; &nbsp; }<br>}<br><br><em>\/\/ \u89c6\u9891\u5904\u7406\u670d\u52a1 - \u6d88\u8d39\u8005<\/em><br>@Service<br>public&nbsp;class&nbsp;VideoProcessingConsumer&nbsp;{<br>&nbsp; &nbsp;&nbsp;@KafkaListener(topics =&nbsp;\"video-processing\")<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;processVideo(VideoProcessingEvent event)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u5f02\u6b65\u6267\u884c\u8017\u65f6\u64cd\u4f5c<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; videoProcessor.transcode(event.getVideoId());<br>&nbsp; &nbsp; &nbsp; &nbsp; videoProcessor.generateThumbnails(event.getVideoId());<br>&nbsp; &nbsp; &nbsp; &nbsp; contentModerationService.checkContent(event.getVideoId());<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u53d1\u9001\u5904\u7406\u5b8c\u6210\u901a\u77e5<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; notificationService.notifyUser(event.getUserId(), event.getVideoId());<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u67b6\u6784\u4f18\u52bf<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5feb\u901f\u54cd\u5e94<\/strong>\uff1a\u7528\u6237\u4e0a\u4f20\u540e\u7acb\u5373\u5f97\u5230\u54cd\u5e94<\/li>\n\n\n\n<li><strong>\u5f39\u6027\u6269\u5c55<\/strong>\uff1a\u53ef\u4ee5\u6839\u636e\u5904\u7406\u538b\u529b\u52a8\u6001\u8c03\u6574\u6d88\u8d39\u8005\u6570\u91cf<\/li>\n\n\n\n<li><strong>\u6545\u969c\u9694\u79bb<\/strong>\uff1a\u5904\u7406\u670d\u52a1\u6545\u969c\u4e0d\u4f1a\u5f71\u54cd\u4e0a\u4f20\u529f\u80fd<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u573a\u666f\u4e09\uff1a\u6d41\u91cf\u524a\u5cf0<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u80cc\u666f\u63cf\u8ff0<\/strong><\/h3>\n\n\n\n<p>\u7535\u5546\u79d2\u6740\u6d3b\u52a8\u65f6\uff0c\u77ac\u65f6\u6d41\u91cf\u53ef\u80fd\u662f\u5e73\u65f6\u7684\u767e\u500d\u4ee5\u4e0a\uff0c\u76f4\u63a5\u51b2\u51fb\u6570\u636e\u5e93\u548c\u670d\u52a1\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>MQ\u89e3\u51b3\u65b9\u6848<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"341\" height=\"499\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044009230.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-6665 lazyload\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044009230.png 341w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044009230-205x300.png 205w\" sizes=\"auto, (max-width: 341px) 100vw, 341px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"341\" height=\"499\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044009230.png\" alt=\"\" class=\"wp-image-6665\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044009230.png 341w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044009230-205x300.png 205w\" sizes=\"auto, (max-width: 341px) 100vw, 341px\" \/><\/noscript><\/figure>\n\n\n\n<p><strong>\u4ee3\u7801\u5b9e\u73b0<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ \u79d2\u6740\u670d\u52a1<\/em><br>@Service<br>public&nbsp;class&nbsp;SecKillService&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;RedisTemplate&lt;String, Object&gt; redisTemplate;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;RabbitTemplate rabbitTemplate;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;public&nbsp;SecKillResponse&nbsp;secKill(SecKillRequest request)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 1. \u6821\u9a8c\u7528\u6237\u8d44\u683c<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(!checkUserQualification(request.getUserId())) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;SecKillResponse.failed(\"\u7528\u6237\u65e0\u8d44\u683c\");<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 2. \u9884\u51cf\u5e93\u5b58\uff08Redis\u539f\u5b50\u64cd\u4f5c\uff09<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; Long remaining = redisTemplate.opsForValue().decrement(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"sec_kill_stock:\"&nbsp;+ request.getItemId());<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(remaining ==&nbsp;null&nbsp;|| remaining &lt;&nbsp;0) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u5e93\u5b58\u4e0d\u8db3\uff0c\u6062\u590d\u5e93\u5b58<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; redisTemplate.opsForValue().increment(\"sec_kill_stock:\"&nbsp;+ request.getItemId());<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;SecKillResponse.failed(\"\u5e93\u5b58\u4e0d\u8db3\");<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 3. \u53d1\u9001\u79d2\u6740\u6210\u529f\u6d88\u606f\u5230MQ<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; rabbitTemplate.convertAndSend(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"sec_kill.exchange\",<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"sec_kill.success\",<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;new&nbsp;SecKillSuccessEvent(request.getUserId(), request.getItemId())<br>&nbsp; &nbsp; &nbsp; &nbsp; );<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;SecKillResponse.success(\"\u79d2\u6740\u6210\u529f\");<br>&nbsp; &nbsp; }<br>}<br><br><em>\/\/ \u8ba2\u5355\u5904\u7406\u6d88\u8d39\u8005<\/em><br>@Component<br>@RabbitListener(queues =&nbsp;\"sec_kill.order.queue\")<br>public&nbsp;class&nbsp;SecKillOrderConsumer&nbsp;{<br>&nbsp; &nbsp;&nbsp;@RabbitHandler<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;handleSecKillSuccess(SecKillSuccessEvent event)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u5f02\u6b65\u521b\u5efa\u8ba2\u5355<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; orderService.createSecKillOrder(event.getUserId(), event.getItemId());<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u6280\u672f\u8981\u70b9<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5e93\u5b58\u9884\u6263<\/strong>\uff1a\u4f7f\u7528Redis\u539f\u5b50\u64cd\u4f5c\u907f\u514d\u8d85\u5356<\/li>\n\n\n\n<li><strong>\u961f\u5217\u7f13\u51b2<\/strong>\uff1aMQ\u7f13\u51b2\u8bf7\u6c42\uff0c\u907f\u514d\u76f4\u63a5\u51b2\u51fb\u6570\u636e\u5e93<\/li>\n\n\n\n<li><strong>\u9650\u6d41\u63a7\u5236<\/strong>\uff1a\u5728\u7f51\u5173\u5c42\u8fdb\u884c\u9650\u6d41\uff0c\u62d2\u7edd\u8fc7\u591a\u8bf7\u6c42<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u573a\u666f\u56db\uff1a\u6570\u636e\u540c\u6b65<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u80cc\u666f\u63cf\u8ff0<\/strong><\/h3>\n\n\n\n<p>\u5728\u5fae\u670d\u52a1\u67b6\u6784\u4e2d\uff0c\u4e0d\u540c\u670d\u52a1\u6709\u81ea\u5df1\u7684\u6570\u636e\u5e93\uff0c\u9700\u8981\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>MQ\u89e3\u51b3\u65b9\u6848<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ \u7528\u6237\u670d\u52a1 - \u6570\u636e\u53d8\u66f4\u65f6\u53d1\u9001\u6d88\u606f<\/em><br>@Service<br>public&nbsp;class&nbsp;UserService&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Transactional<br>&nbsp; &nbsp;&nbsp;public&nbsp;User&nbsp;updateUser(User user)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 1. \u66f4\u65b0\u6570\u636e\u5e93<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; userDao.update(user);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 2. \u53d1\u9001\u6d88\u606f\uff08\u5728\u4e8b\u52a1\u5185\uff09<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; rocketMQTemplate.sendMessageInTransaction(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"user-update-topic\",<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBuilder.withPayload(new&nbsp;UserUpdateEvent(user.getId(), user.getStatus()))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .build(),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;null<br>&nbsp; &nbsp; &nbsp; &nbsp; );<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;user;<br>&nbsp; &nbsp; }<br>}<br><br><em>\/\/ \u5176\u4ed6\u670d\u52a1 - \u6d88\u8d39\u7528\u6237\u66f4\u65b0\u6d88\u606f<\/em><br>@Service<br>@RocketMQMessageListener(topic =&nbsp;\"user-update-topic\", consumerGroup =&nbsp;\"order-group\")<br>public&nbsp;class&nbsp;UserUpdateConsumer&nbsp;implements&nbsp;RocketMQListener&lt;UserUpdateEvent&gt;&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Override<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;onMessage(UserUpdateEvent event)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u66f4\u65b0\u672c\u5730\u7528\u6237\u4fe1\u606f\u7f13\u5b58<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; orderService.updateUserCache(event.getUserId(), event.getStatus());<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u4e00\u81f4\u6027\u4fdd\u8bc1<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u672c\u5730\u4e8b\u52a1\u8868<\/strong>\uff1a\u5c06\u6d88\u606f\u548c\u4e1a\u52a1\u6570\u636e\u653e\u5728\u540c\u4e00\u4e2a\u6570\u636e\u5e93\u4e8b\u52a1\u4e2d<\/li>\n\n\n\n<li><strong>\u4e8b\u52a1\u6d88\u606f<\/strong>\uff1a\u4f7f\u7528RocketMQ\u7684\u4e8b\u52a1\u6d88\u606f\u673a\u5236<\/li>\n\n\n\n<li><strong>\u5e42\u7b49\u6d88\u8d39<\/strong>\uff1a\u6d88\u8d39\u8005\u5b9e\u73b0\u5e42\u7b49\u6027\uff0c\u907f\u514d\u91cd\u590d\u5904\u7406<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u573a\u666f\u4e94\uff1a\u65e5\u5fd7\u6536\u96c6<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u80cc\u666f\u63cf\u8ff0<\/strong><\/h3>\n\n\n\n<p>\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\uff0c\u65e5\u5fd7\u5206\u6563\u5728\u5404\u4e2a\u8282\u70b9\uff0c\u9700\u8981\u96c6\u4e2d\u6536\u96c6\u548c\u5206\u6790\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>MQ\u89e3\u51b3\u65b9\u6848<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"474\" height=\"407\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044018770.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-6666 lazyload\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044018770.png 474w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044018770-300x258.png 300w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"474\" height=\"407\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044018770.png\" alt=\"\" class=\"wp-image-6666\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044018770.png 474w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044018770-300x258.png 300w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/noscript><\/figure>\n\n\n\n<p><strong>\u4ee3\u7801\u5b9e\u73b0<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ \u65e5\u5fd7\u6536\u96c6\u7ec4\u4ef6<\/em><br>@Component<br>public&nbsp;class&nbsp;LogCollector&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;KafkaTemplate&lt;String, String&gt; kafkaTemplate;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;collectLog(String appId, String level, String message, Map&lt;String, Object&gt; context)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; LogEvent logEvent =&nbsp;new&nbsp;LogEvent(appId, level, message, context, System.currentTimeMillis());<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u53d1\u9001\u5230Kafka<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; kafkaTemplate.send(\"app-logs\", appId, JsonUtils.toJson(logEvent));<br>&nbsp; &nbsp; }<br>}<br><br><em>\/\/ \u65e5\u5fd7\u6d88\u8d39\u8005<\/em><br>@Service<br>public&nbsp;class&nbsp;LogConsumer&nbsp;{<br>&nbsp; &nbsp;&nbsp;@KafkaListener(topics =&nbsp;\"app-logs\", groupId =&nbsp;\"log-es\")<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;consumeLog(String message)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; LogEvent logEvent = JsonUtils.fromJson(message, LogEvent.class);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u5b58\u50a8\u5230Elasticsearch<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; elasticsearchService.indexLog(logEvent);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u5b9e\u65f6\u76d1\u63a7\u68c0\u67e5<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(\"ERROR\".equals(logEvent.getLevel())) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alertService.checkAndAlert(logEvent);<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u6280\u672f\u4f18\u52bf<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u89e3\u8026<\/strong>\uff1a\u5e94\u7528\u8282\u70b9\u65e0\u9700\u5173\u5fc3\u65e5\u5fd7\u5982\u4f55\u5904\u7406<\/li>\n\n\n\n<li><strong>\u7f13\u51b2<\/strong>\uff1a\u5e94\u5bf9\u65e5\u5fd7\u4ea7\u751f\u901f\u7387\u6ce2\u52a8<\/li>\n\n\n\n<li><strong>\u591a\u6d88\u8d39<\/strong>\uff1a\u540c\u4e00\u4efd\u65e5\u5fd7\u53ef\u4ee5\u88ab\u591a\u4e2a\u6d88\u8d39\u8005\u5904\u7406<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u573a\u666f\u516d\uff1a\u6d88\u606f\u5e7f\u64ad<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u80cc\u666f\u63cf\u8ff0<\/strong><\/h3>\n\n\n\n<p>\u7cfb\u7edf\u914d\u7f6e\u66f4\u65b0\u540e\uff0c\u9700\u8981\u901a\u77e5\u6240\u6709\u670d\u52a1\u8282\u70b9\u66f4\u65b0\u672c\u5730\u914d\u7f6e\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>MQ\u89e3\u51b3\u65b9\u6848<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ \u914d\u7f6e\u670d\u52a1 - \u5e7f\u64ad\u914d\u7f6e\u66f4\u65b0<\/em><br>@Service<br>public&nbsp;class&nbsp;ConfigService&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;RedisTemplate&lt;String, Object&gt; redisTemplate;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;updateConfig(String configKey, String configValue)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 1. \u66f4\u65b0\u914d\u7f6e\u5b58\u50a8<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; configDao.updateConfig(configKey, configValue);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 2. \u5e7f\u64ad\u914d\u7f6e\u66f4\u65b0\u6d88\u606f<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; redisTemplate.convertAndSend(\"config-update-channel\",&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;new&nbsp;ConfigUpdateEvent(configKey, configValue));<br>&nbsp; &nbsp; }<br>}<br><br><em>\/\/ \u670d\u52a1\u8282\u70b9 - \u8ba2\u9605\u914d\u7f6e\u66f4\u65b0<\/em><br>@Component<br>public&nbsp;class&nbsp;ConfigUpdateListener&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;LocalConfigCache localConfigCache;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;@RedisListener(channel =&nbsp;\"config-update-channel\")<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;handleConfigUpdate(ConfigUpdateEvent event)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u66f4\u65b0\u672c\u5730\u914d\u7f6e\u7f13\u5b58<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; localConfigCache.updateConfig(event.getKey(), event.getValue());<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u5e94\u7528\u573a\u666f<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u529f\u80fd\u5f00\u5173<\/strong>\uff1a\u52a8\u6001\u5f00\u542f\u6216\u5173\u95ed\u529f\u80fd<\/li>\n\n\n\n<li><strong>\u53c2\u6570\u8c03\u6574<\/strong>\uff1a\u8c03\u6574\u8d85\u65f6\u65f6\u95f4\u3001\u9650\u6d41\u9608\u503c\u7b49<\/li>\n\n\n\n<li><strong>\u9ed1\u767d\u540d\u5355<\/strong>\uff1a\u66f4\u65b0\u9ed1\u767d\u540d\u5355\u914d\u7f6e<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u573a\u666f\u4e03\uff1a\u987a\u5e8f\u6d88\u606f<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u80cc\u666f\u63cf\u8ff0<\/strong><\/h3>\n\n\n\n<p>\u5728\u67d0\u4e9b\u4e1a\u52a1\u573a\u666f\u4e2d\uff0c\u6d88\u606f\u7684\u5904\u7406\u987a\u5e8f\u5f88\u91cd\u8981\uff0c\u5982\u8ba2\u5355\u72b6\u6001\u53d8\u66f4\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>MQ\u89e3\u51b3\u65b9\u6848<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ \u8ba2\u5355\u72b6\u6001\u53d8\u66f4\u670d\u52a1<\/em><br>@Service<br>public&nbsp;class&nbsp;OrderStateService&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;RocketMQTemplate rocketMQTemplate;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;changeOrderState(String orderId, String oldState, String newState)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; OrderStateEvent event =&nbsp;new&nbsp;OrderStateEvent(orderId, oldState, newState);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u53d1\u9001\u987a\u5e8f\u6d88\u606f\uff0c\u4f7f\u7528orderId\u4f5c\u4e3asharding key<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; rocketMQTemplate.syncSendOrderly(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"order-state-topic\",&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event,&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; orderId &nbsp;<em>\/\/ \u4fdd\u8bc1\u540c\u4e00\u8ba2\u5355\u7684\u6d88\u606f\u6309\u987a\u5e8f\u5904\u7406<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; );<br>&nbsp; &nbsp; }<br>}<br><br><em>\/\/ \u8ba2\u5355\u72b6\u6001\u6d88\u8d39\u8005<\/em><br>@Service<br>@RocketMQMessageListener(<br>&nbsp; &nbsp; topic =&nbsp;\"order-state-topic\",<br>&nbsp; &nbsp; consumerGroup =&nbsp;\"order-state-group\",<br>&nbsp; &nbsp; consumeMode = ConsumeMode.ORDERLY &nbsp;<em>\/\/ \u987a\u5e8f\u6d88\u8d39<\/em><br>)<br>public&nbsp;class&nbsp;OrderStateConsumer&nbsp;implements&nbsp;RocketMQListener&lt;OrderStateEvent&gt;&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Override<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;onMessage(OrderStateEvent event)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u6309\u987a\u5e8f\u5904\u7406\u8ba2\u5355\u72b6\u6001\u53d8\u66f4<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; orderService.processStateChange(event);<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u987a\u5e8f\u4fdd\u8bc1\u673a\u5236<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5206\u533a\u987a\u5e8f<\/strong>\uff1a\u540c\u4e00\u5206\u533a\u5185\u7684\u6d88\u606f\u4fdd\u8bc1\u987a\u5e8f<\/li>\n\n\n\n<li><strong>\u987a\u5e8f\u6295\u9012<\/strong>\uff1aMQ\u4fdd\u8bc1\u6d88\u606f\u6309\u53d1\u9001\u987a\u5e8f\u6295\u9012<\/li>\n\n\n\n<li><strong>\u987a\u5e8f\u5904\u7406<\/strong>\uff1a\u6d88\u8d39\u8005\u987a\u5e8f\u5904\u7406\u6d88\u606f<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u573a\u666f\u516b\uff1a\u5ef6\u8fdf\u6d88\u606f<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u80cc\u666f\u63cf\u8ff0<\/strong><\/h3>\n\n\n\n<p>\u9700\u8981\u5b9e\u73b0\u5b9a\u65f6\u4efb\u52a1\uff0c\u5982\u8ba2\u5355\u8d85\u65f6\u672a\u652f\u4ed8\u81ea\u52a8\u53d6\u6d88\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>MQ\u89e3\u51b3\u65b9\u6848<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ \u8ba2\u5355\u670d\u52a1 - \u53d1\u9001\u5ef6\u8fdf\u6d88\u606f<\/em><br>@Service<br>public&nbsp;class&nbsp;OrderService&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;RabbitTemplate rabbitTemplate;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;createOrder(Order order)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u4fdd\u5b58\u8ba2\u5355<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; orderDao.save(order);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u53d1\u9001\u5ef6\u8fdf\u6d88\u606f\uff0c30\u5206\u949f\u540e\u68c0\u67e5\u652f\u4ed8\u72b6\u6001<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; rabbitTemplate.convertAndSend(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"order.delay.exchange\",<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"order.create\",<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;new&nbsp;OrderCreateEvent(order.getId()),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message -&gt; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message.getMessageProperties().setDelay(30&nbsp;*&nbsp;60&nbsp;*&nbsp;1000);&nbsp;<em>\/\/ 30\u5206\u949f<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;message;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; );<br>&nbsp; &nbsp; }<br>}<br><br><em>\/\/ \u8ba2\u5355\u8d85\u65f6\u68c0\u67e5\u6d88\u8d39\u8005<\/em><br>@Component<br>@RabbitListener(queues =&nbsp;\"order.delay.queue\")<br>public&nbsp;class&nbsp;OrderTimeoutConsumer&nbsp;{<br>&nbsp; &nbsp;&nbsp;@RabbitHandler<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;checkOrderPayment(OrderCreateEvent event)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; Order order = orderDao.findById(event.getOrderId());<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(\"UNPAID\".equals(order.getStatus())) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u8d85\u65f6\u672a\u652f\u4ed8\uff0c\u53d6\u6d88\u8ba2\u5355<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; orderService.cancelOrder(order.getId(),&nbsp;\"\u8d85\u65f6\u672a\u652f\u4ed8\");<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u66ff\u4ee3\u65b9\u6848\u5bf9\u6bd4<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u65b9\u6848<\/th><th>\u4f18\u70b9<\/th><th>\u7f3a\u70b9<\/th><\/tr><\/thead><tbody><tr><td><strong>\u6570\u636e\u5e93\u8f6e\u8be2<\/strong><\/td><td>\u5b9e\u73b0\u7b80\u5355<\/td><td>\u5b9e\u65f6\u6027\u5dee\uff0c\u6570\u636e\u5e93\u538b\u529b\u5927<\/td><\/tr><tr><td><strong>\u5ef6\u65f6\u961f\u5217<\/strong><\/td><td>\u5b9e\u65f6\u6027\u597d<\/td><td>\u5b9e\u73b0\u590d\u6742\uff0c\u6d88\u606f\u5806\u79ef\u95ee\u9898<\/td><\/tr><tr><td><strong>\u5b9a\u65f6\u4efb\u52a1<\/strong><\/td><td>\u53ef\u63a7\u6027\u5f3a<\/td><td>\u5206\u5e03\u5f0f\u534f\u8c03\u590d\u6742<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u573a\u666f\u4e5d\uff1a\u6d88\u606f\u91cd\u8bd5<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u80cc\u666f\u63cf\u8ff0<\/strong><\/h3>\n\n\n\n<p>\u5904\u7406\u6d88\u606f\u65f6\u53ef\u80fd\u9047\u5230\u4e34\u65f6\u6545\u969c\uff0c\u9700\u8981\u91cd\u8bd5\u673a\u5236\u4fdd\u8bc1\u6700\u7ec8\u5904\u7406\u6210\u529f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>MQ\u89e3\u51b3\u65b9\u6848<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ \u6d88\u606f\u6d88\u8d39\u8005 with \u91cd\u8bd5\u673a\u5236<\/em><br>@Service<br>@Slf4j<br>public&nbsp;class&nbsp;RetryableConsumer&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;RabbitTemplate rabbitTemplate;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;@RabbitListener(queues =&nbsp;\"business.queue\")<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;processMessage(Message message, Channel channel)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;try&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u4e1a\u52a1\u5904\u7406<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; businessService.process(message);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u786e\u8ba4\u6d88\u606f<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; channel.basicAck(message.getMessageProperties().getDeliveryTag(),&nbsp;false);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;catch&nbsp;(TemporaryException e) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u4e34\u65f6\u5f02\u5e38\uff0c\u91cd\u8bd5<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log.warn(\"\u5904\u7406\u5931\u8d25\uff0c\u51c6\u5907\u91cd\u8bd5\", e);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u62d2\u7edd\u6d88\u606f\uff0crequeue=true<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; channel.basicNack(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message.getMessageProperties().getDeliveryTag(),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;false,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;true<em>\/\/ \u91cd\u65b0\u5165\u961f<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;catch&nbsp;(PermanentException e) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u6c38\u4e45\u5f02\u5e38\uff0c\u8fdb\u5165\u6b7b\u4fe1\u961f\u5217<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log.error(\"\u5904\u7406\u5931\u8d25\uff0c\u8fdb\u5165\u6b7b\u4fe1\u961f\u5217\", e);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; channel.basicNack(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message.getMessageProperties().getDeliveryTag(),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;false,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;false<em>\/\/ \u4e0d\u91cd\u65b0\u5165\u961f<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u91cd\u8bd5\u7b56\u7565<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u7acb\u5373\u91cd\u8bd5<\/strong>\uff1a\u4e34\u65f6\u6545\u969c\u7acb\u5373\u91cd\u8bd5<\/li>\n\n\n\n<li><strong>\u5ef6\u8fdf\u91cd\u8bd5<\/strong>\uff1a\u9010\u6b65\u589e\u52a0\u91cd\u8bd5\u95f4\u9694<\/li>\n\n\n\n<li><strong>\u6b7b\u4fe1\u961f\u5217<\/strong>\uff1a\u6700\u7ec8\u65e0\u6cd5\u5904\u7406\u7684\u6d88\u606f\u8fdb\u5165\u6b7b\u4fe1\u961f\u5217<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u573a\u666f\u5341\uff1a\u4e8b\u52a1\u6d88\u606f<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u80cc\u666f\u63cf\u8ff0<\/strong><\/h3>\n\n\n\n<p>\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\uff0c\u9700\u8981\u4fdd\u8bc1\u591a\u4e2a\u670d\u52a1\u7684\u6570\u636e\u4e00\u81f4\u6027\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>MQ\u89e3\u51b3\u65b9\u6848<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ \u4e8b\u52a1\u6d88\u606f\u751f\u4ea7\u8005<\/em><br>@Service<br>public&nbsp;class&nbsp;TransactionalMessageService&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;RocketMQTemplate rocketMQTemplate;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;@Transactional<br>&nbsp; &nbsp;&nbsp;public&nbsp;void&nbsp;createOrderWithTransaction(Order order)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 1. \u4fdd\u5b58\u8ba2\u5355\uff08\u6570\u636e\u5e93\u4e8b\u52a1\uff09<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; orderDao.save(order);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ 2. \u53d1\u9001\u4e8b\u52a1\u6d88\u606f<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; TransactionSendResult result = rocketMQTemplate.sendMessageInTransaction(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"order-tx-topic\",<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBuilder.withPayload(new&nbsp;OrderCreatedEvent(order.getId()))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .build(),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; order &nbsp;<em>\/\/ \u4e8b\u52a1\u53c2\u6570<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; );<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(!result.getLocalTransactionState().equals(LocalTransactionState.COMMIT_MESSAGE)) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;thrownew&nbsp;RuntimeException(\"\u4e8b\u52a1\u6d88\u606f\u53d1\u9001\u5931\u8d25\");<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<br><br><em>\/\/ \u4e8b\u52a1\u6d88\u606f\u76d1\u542c\u5668<\/em><br>@Component<br>@RocketMQTransactionListener<br>public&nbsp;class&nbsp;OrderTransactionListener&nbsp;implements&nbsp;RocketMQLocalTransactionListener&nbsp;{<br>&nbsp; &nbsp;&nbsp;@Autowired<br>&nbsp; &nbsp;&nbsp;private&nbsp;OrderDao orderDao;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;@Override<br>&nbsp; &nbsp;&nbsp;public&nbsp;RocketMQLocalTransactionState&nbsp;executeLocalTransaction(Message msg, Object arg)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;try&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u68c0\u67e5\u672c\u5730\u4e8b\u52a1\u72b6\u6001<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Order order = (Order) arg;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Order existOrder = orderDao.findById(order.getId());<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(existOrder !=&nbsp;null&nbsp;&amp;&amp;&nbsp;\"CREATED\".equals(existOrder.getStatus())) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;RocketMQLocalTransactionState.COMMIT_MESSAGE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;else&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;RocketMQLocalTransactionState.ROLLBACK_MESSAGE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;catch&nbsp;(Exception e) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;RocketMQLocalTransactionState.UNKNOWN;<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;@Override<br>&nbsp; &nbsp;&nbsp;public&nbsp;RocketMQLocalTransactionState&nbsp;checkLocalTransaction(Message msg)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>\/\/ \u56de\u67e5\u672c\u5730\u4e8b\u52a1\u72b6\u6001<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; String orderId = (String) msg.getHeaders().get(\"order_id\");<br>&nbsp; &nbsp; &nbsp; &nbsp; Order order = orderDao.findById(orderId);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(order !=&nbsp;null&nbsp;&amp;&amp;&nbsp;\"CREATED\".equals(order.getStatus())) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;RocketMQLocalTransactionState.COMMIT_MESSAGE;<br>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;else&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;RocketMQLocalTransactionState.ROLLBACK_MESSAGE;<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u4e8b\u52a1\u6d88\u606f\u6d41\u7a0b<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"472\" height=\"652\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044029875.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-6667 lazyload\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044029875.png 472w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044029875-217x300.png 217w\" sizes=\"auto, (max-width: 472px) 100vw, 472px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"472\" height=\"652\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044029875.png\" alt=\"\" class=\"wp-image-6667\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044029875.png 472w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044029875-217x300.png 217w\" sizes=\"auto, (max-width: 472px) 100vw, 472px\" \/><\/noscript><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u603b\u7ed3<\/strong><\/h2>\n\n\n\n<p>\u901a\u8fc7\u4ee5\u4e0a10\u4e2a\u573a\u666f\uff0c\u6211\u4eec\u53ef\u4ee5\u603b\u7ed3\u51faMQ\u4f7f\u7528\u7684\u6838\u5fc3\u539f\u5219\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u9002\u7528\u573a\u666f<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5f02\u6b65\u5904\u7406<\/strong>\uff1a\u63d0\u5347\u7cfb\u7edf\u54cd\u5e94\u901f\u5ea6<\/li>\n\n\n\n<li><strong>\u7cfb\u7edf\u89e3\u8026<\/strong>\uff1a\u964d\u4f4e\u7cfb\u7edf\u95f4\u4f9d\u8d56<\/li>\n\n\n\n<li><strong>\u6d41\u91cf\u524a\u5cf0<\/strong>\uff1a\u5e94\u5bf9\u7a81\u53d1\u6d41\u91cf<\/li>\n\n\n\n<li><strong>\u6570\u636e\u540c\u6b65<\/strong>\uff1a\u4fdd\u8bc1\u6700\u7ec8\u4e00\u81f4\u6027<\/li>\n\n\n\n<li><strong>\u5206\u5e03\u5f0f\u4e8b\u52a1<\/strong>\uff1a\u89e3\u51b3\u6570\u636e\u4e00\u81f4\u6027\u95ee\u9898<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u6280\u672f\u9009\u578b\u5efa\u8bae<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u573a\u666f<\/th><th>\u63a8\u8350MQ<\/th><th>\u539f\u56e0<\/th><\/tr><\/thead><tbody><tr><td>\u9ad8\u541e\u5410<\/td><td>Kafka<\/td><td>\u9ad8\u541e\u5410\u91cf\uff0c\u6301\u4e45\u5316\u5b58\u50a8<\/td><\/tr><tr><td>\u4e8b\u52a1\u6d88\u606f<\/td><td>RocketMQ<\/td><td>\u5b8c\u6574\u7684\u4e8b\u52a1\u6d88\u606f\u673a\u5236<\/td><\/tr><tr><td>\u590d\u6742\u8def\u7531<\/td><td>RabbitMQ<\/td><td>\u7075\u6d3b\u7684\u8def\u7531\u914d\u7f6e<\/td><\/tr><tr><td>\u5ef6\u8fdf\u6d88\u606f<\/td><td>RabbitMQ<\/td><td>\u539f\u751f\u652f\u6301\u5ef6\u8fdf\u961f\u5217<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><\/strong><strong>\u6700\u4f73\u5b9e\u8df5<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6d88\u606f\u5e42\u7b49\u6027<\/strong>\uff1a\u6d88\u8d39\u8005\u5fc5\u987b\u5b9e\u73b0\u5e42\u7b49\u5904\u7406<\/li>\n\n\n\n<li><strong>\u6b7b\u4fe1\u961f\u5217<\/strong>\uff1a\u5904\u7406\u5931\u8d25\u7684\u6d88\u606f\u8981\u6709\u515c\u5e95\u65b9\u6848<\/li>\n\n\n\n<li><strong>\u76d1\u63a7\u544a\u8b66<\/strong>\uff1a\u5b8c\u5584\u7684\u6d88\u606f\u5806\u79ef\u76d1\u63a7\u548c\u544a\u8b66<\/li>\n\n\n\n<li><strong>\u6027\u80fd\u4f18\u5316<\/strong>\uff1a\u6839\u636e\u4e1a\u52a1\u7279\u70b9\u8c03\u6574MQ\u53c2\u6570<\/li>\n<\/ol>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u4e3a\u4ec0\u4e48\u9700\u8981\u6d88\u606f\u961f\u5217\uff08MQ\uff09\uff1f \u5728\u6df1\u5165\u5177\u4f53\u573a\u666f\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u6765\u601d\u8003\u4e00\u4e2a\u57fa\u672c\u95ee\u9898\uff1a\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u6d88\u606f\u961f\u5217\uff1f \u7cfb\u7edf\u95f4\u7684\u76f4\u63a5\u8c03\u7528\uff1a \u5f15\u5165\u6d88 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[34],"tags":[],"class_list":["post-6663","post","type-post","status-publish","format-standard","hentry","category-34"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png","post_all_images":[{"imagesurl":"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/ibJZVicC7nz5jIGEsda6wC9h7xtUCe5VicsBp3CIb6r1YUgdStULZht5SCicLYWO4XEJk0TsaSRplpYoXngT3MuibGA\/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=1","id":"image0"},{"imagesurl":"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/ibJZVicC7nz5jIGEsda6wC9h7xtUCe5VicsBp3CIb6r1YUgdStULZht5SCicLYWO4XEJk0TsaSRplpYoXngT3MuibGA\/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=1","id":"image1"},{"imagesurl":"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/ibJZVicC7nz5jIGEsda6wC9h7xtUCe5VicsPvEMm76ic5qhhiavE30X9P4NVrTSoKBSlfBjSdFAnpx486EpjxdFyVqA\/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=2","id":"image2"},{"imagesurl":"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/ibJZVicC7nz5jIGEsda6wC9h7xtUCe5VicsPvEMm76ic5qhhiavE30X9P4NVrTSoKBSlfBjSdFAnpx486EpjxdFyVqA\/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=2","id":"image3"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png","id":"image4"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929043958149.png","id":"image5"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044009230.png","id":"image6"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044009230.png","id":"image7"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044018770.png","id":"image8"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044018770.png","id":"image9"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044029875.png","id":"image10"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929044029875.png","id":"image11"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"\u961f\u5217","post_date":"2025-09-29","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":215,"next_post_id":null,"next_post_title":null,"previous_post_id":4959,"previous_post_title":"\u6d88\u606f\u961f\u5217\u7684\u4e03\u79cd\u7ecf\u5178\u5e94\u7528\u573a\u666f","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=6663"}],"version-history":[{"count":1,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6663\/revisions"}],"predecessor-version":[{"id":6668,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6663\/revisions\/6668"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=6663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=6663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=6663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}