[{"data":1,"prerenderedAt":178},["ShallowReactive",2],{"content-/blog/message-queue":3,"related-blog":153},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"keywords":10,"author":11,"date":12,"category":13,"image":14,"body":15,"_type":147,"_id":148,"_source":149,"_file":150,"_stem":151,"_extension":152},"/blog/message-queue","blog",false,"","消息队列应用","使用消息队列实现异步处理、削峰填谷、系统解耦","消息队列应用, Blog, HTMLPAGE","HTMLPAGE","2025-11-26","待分类","/content-images/blog/blog.jpg",{"type":16,"children":17,"toc":140},"root",[18,26,32,68,73,91,96,109,113,118],{"type":19,"tag":20,"props":21,"children":22},"element","p",{},[23],{"type":24,"value":25},"text","消息队列在生成平台中用于解耦和弹性调度长耗时任务（如批量生成、图像处理、异步外部调用）。本文比较常见队列方案并提供工程实践。",{"type":19,"tag":27,"props":28,"children":30},"h2",{"id":29},"常见队列方案",[31],{"type":24,"value":29},{"type":19,"tag":33,"props":34,"children":35},"ul",{},[36,48,58],{"type":19,"tag":37,"props":38,"children":39},"li",{},[40,46],{"type":19,"tag":41,"props":42,"children":43},"strong",{},[44],{"type":24,"value":45},"RabbitMQ",{"type":24,"value":47},"：适合复杂路由与确认语义的场景，支持多种交换机类型。",{"type":19,"tag":37,"props":49,"children":50},{},[51,56],{"type":19,"tag":41,"props":52,"children":53},{},[54],{"type":24,"value":55},"Kafka",{"type":24,"value":57},"：适合高吞吐、事件流场景，常用于事件溯源与日志型数据。",{"type":19,"tag":37,"props":59,"children":60},{},[61,66],{"type":19,"tag":41,"props":62,"children":63},{},[64],{"type":24,"value":65},"BullMQ / Redis Streams",{"type":24,"value":67},"：适合 Node.js 场景的轻量队列，支持延迟与重试。",{"type":19,"tag":27,"props":69,"children":71},{"id":70},"设计原则",[72],{"type":24,"value":70},{"type":19,"tag":33,"props":74,"children":75},{},[76,81,86],{"type":19,"tag":37,"props":77,"children":78},{},[79],{"type":24,"value":80},"幂等性：消费者必须设计为幂等以应对重试或重复投递。",{"type":19,"tag":37,"props":82,"children":83},{},[84],{"type":24,"value":85},"可监控性：暴露队列深度、处理延迟、失败率等指标，便于自动告警与伸缩决策。",{"type":19,"tag":37,"props":87,"children":88},{},[89],{"type":24,"value":90},"重试与死信队列：对可恢复和不可恢复错误分别处理，失败次数超过阈值时进入死信队列以便人工审查。",{"type":19,"tag":27,"props":92,"children":94},{"id":93},"实践建议",[95],{"type":24,"value":93},{"type":19,"tag":33,"props":97,"children":98},{},[99,104],{"type":19,"tag":37,"props":100,"children":101},{},[102],{"type":24,"value":103},"将长任务拆分为更小的子任务，允许并行处理与更精细的重试策略。",{"type":19,"tag":37,"props":105,"children":106},{},[107],{"type":24,"value":108},"使用优先级队列区分交互型短任务与后台批处理，避免长任务阻塞关键路径。",{"type":19,"tag":110,"props":111,"children":112},"hr",{},[],{"type":19,"tag":20,"props":114,"children":115},{},[116],{"type":24,"value":117},"相关链接：",{"type":19,"tag":33,"props":119,"children":120},{},[121,131],{"type":19,"tag":37,"props":122,"children":123},{},[124],{"type":19,"tag":125,"props":126,"children":128},"a",{"href":127},"/blog",[129],{"type":24,"value":130},"返回博客分类",{"type":19,"tag":37,"props":132,"children":133},{},[134],{"type":19,"tag":125,"props":135,"children":137},{"href":136},"/blog/topic/multi-agent-system",[138],{"type":24,"value":139},"查看热门话题",{"title":7,"searchDepth":141,"depth":141,"links":142},3,[143,145,146],{"id":29,"depth":144,"text":29},2,{"id":70,"depth":144,"text":70},{"id":93,"depth":144,"text":93},"markdown","content:blog:message-queue.md","content","blog/message-queue.md","blog/message-queue","md",[154,162,170],{"_path":155,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":156,"description":157,"keywords":158,"author":11,"date":12,"category":13,"image":14,"_type":147,"_id":159,"_source":149,"_file":160,"_stem":161,"_extension":152},"/blog/2025-q1-updates","2025 Q1 产品更新","第一季度重大功能发布：AI 生成优化、新模板上线、编辑器增强等","2025 Q1 产品更新, Blog, HTMLPAGE","content:blog:2025-q1-updates.md","blog/2025-q1-updates.md","blog/2025-q1-updates",{"_path":163,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":164,"description":165,"keywords":166,"author":11,"date":12,"category":13,"image":14,"_type":147,"_id":167,"_source":149,"_file":168,"_stem":169,"_extension":152},"/blog/2025-roadmap","2025 产品路线图","展望 2025 年的产品规划：AI 能力增强、模板扩充、国际化等","2025 产品路线图, Blog, HTMLPAGE","content:blog:2025-roadmap.md","blog/2025-roadmap.md","blog/2025-roadmap",{"_path":171,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":172,"description":173,"keywords":174,"author":11,"date":12,"category":13,"image":14,"_type":147,"_id":175,"_source":149,"_file":176,"_stem":177,"_extension":152},"/blog/ab-testing","A/B 测试","通过 A/B 测试验证设计方案","A/B 测试, Blog, HTMLPAGE","content:blog:ab-testing.md","blog/ab-testing.md","blog/ab-testing",1774945285735]