欢迎使用 FlowZap,快速、清晰、掌控的绘图应用。

事件驱动死信队列架构

Architecture

死信队列架构图,展示重试策略、指数退避、最大重试阈值、失败消息的 DLQ 路由、运维告警和手动重处理工作流。该模板模拟异步消息系统的关键错误处理模式,确保处理失败时不会静默丢失任何消息。对于构建具有适当故障恢复机制的可靠事件驱动系统至关重要。

完整 FlowZap 代码

Producer { # Message Producer
n1: circle label:"Publish Message"
n2: rectangle label:"Serialize Payload"
n3: rectangle label:"Send to Main Queue"
n1.handle(right) -> n2.handle(left)
n2.handle(right) -> n3.handle(left) [label="Enqueue"]
n3.handle(bottom) -> MainQueue.n4.handle(top) [label="Deliver"]
}
MainQueue { # Main Processing Queue
n4: rectangle label:"Receive Message"
n5: rectangle label:"Attempt Processing"
n6: diamond label:"Processing Succeeded?"
n7: rectangle label:"Acknowledge Message"
n8: rectangle label:"Increment Retry Count"
n9: diamond label:"Max Retries Exceeded?"
n4.handle(right) -> n5.handle(left)
n5.handle(right) -> n6.handle(left)
n6.handle(right) -> n7.handle(left) [label="Yes"]
n6.handle(bottom) -> n8.handle(top) [label="No"]
n8.handle(right) -> n9.handle(left)
n9.handle(top) -> n5.handle(bottom) [label="Retry"]
n9.handle(bottom) -> DLQ.n10.handle(top) [label="Exceeded"]
}
DLQ { # Dead Letter Queue
n10: rectangle label:"Route to DLQ"
n11: rectangle label:"Store Failed Message"
n12: rectangle label:"Alert Operations Team"
n13: rectangle label:"Manual Review Dashboard"
n14: diamond label:"Reprocessable?"
n15: rectangle label:"Requeue to Main"
n16: rectangle label:"Archive and Close"
n10.handle(right) -> n11.handle(left) [label="Preserve Context"]
n11.handle(right) -> n12.handle(left) [label="PagerDuty"]
n12.handle(right) -> n13.handle(left)
n13.handle(right) -> n14.handle(left) [label="Investigate"]
n14.handle(right) -> n15.handle(left) [label="Yes"]
n14.handle(bottom) -> n16.handle(top) [label="No"]
n15.handle(top) -> MainQueue.n4.handle(bottom) [label="Replay"]
}

为什么需要这个工作流?

Without proper error handling, failed messages in event-driven systems are silently lost or cause infinite retry loops that waste resources. A dead letter queue captures messages that exceed retry thresholds, preserving them for investigation and manual reprocessing while keeping the main processing pipeline healthy.

工作原理

  1. Step 1: A message is received from the main queue and processing is attempted.
  2. Step 2: If processing fails, the retry count is incremented and the message is requeued.
  3. Step 3: Exponential backoff delays prevent overwhelming the failing service.
  4. Step 4: After exceeding the maximum retry threshold, the message is routed to the DLQ.
  5. Step 5: Operations teams are alerted via PagerDuty and can investigate through a dashboard.
  6. Step 6: Reprocessable messages are requeued to the main queue after the root cause is fixed.

替代方案

Ignoring failed messages leads to data loss. Infinite retries waste resources and mask bugs. Logging failures without a DLQ makes recovery difficult. This template shows the complete failure handling lifecycle.

Key Facts

Template Name事件驱动死信队列架构
CategoryArchitecture
Steps6 workflow steps
FormatFlowZap Code (.fz file)

相关模板

事件驱动发布-订阅架构

Architecture

事件驱动发布-订阅架构图,展示 Kafka 或 RabbitMQ 消息代理、事件序列化、主题分区、向多个消费者的扇出交付以及死信队列错误处理。该模板模拟了生产者和消费者通过消息代理完全解耦的基础异步消息传递模式。对于构建松耦合、可扩展的事件驱动系统的架构师至关重要。

指数退避重试架构

Architecture

指数退避重试架构图,展示完整的重试策略引擎,包括可重试与不可重试错误分类、带抖动的指数延迟计算、最大重试阈值和优雅的耗尽处理。该模板模拟处理分布式系统中瞬态故障的基本弹性模式,通过随机退避延迟防止惊群问题。对于云架构中任何服务间通信都是基础性的。

微服务 API 网关架构

Architecture

微服务 API 网关架构图,展示请求路由、JWT 身份验证、速率限制、服务发现以及跨分布式后端服务的响应聚合。该模板模拟微服务生态系统中所有客户端流量的入口点,在请求到达内部服务之前执行安全策略。适合设计具有集中式横切关注点的可扩展 API 基础设施的平台工程师。

微服务服务网格架构

Architecture

服务网格架构图,展示 Istio 或 Linkerd 边车代理处理 mTLS 加密、流量策略、熔断器和跨微服务的分布式追踪。该模板可视化服务网格如何将网络关注点从应用代码中抽象出来,实现服务间的零信任通信。对于采用服务网格基础设施以提升可观测性和安全性的团队至关重要。

微服务每服务独立数据库架构

Architecture

每服务独立数据库架构图,每个微服务拥有其专用数据存储,通过 Kafka 进行事件驱动同步以实现跨服务数据一致性。该模板展示了微服务数据隔离的核心原则,展示 PostgreSQL 和 MongoDB 如何在多语言持久化策略中共存。对于在保持最终一致性的同时强制服务自治的架构师至关重要。

按业务能力分解微服务架构

Architecture

按业务能力组织的微服务分解架构图:身份认证、产品目录、定价和订单履行,每个都有独立的数据存储和 API。该模板展示如何将单体应用拆分为与业务领域对齐的服务,使用 Backend-for-Frontend (BFF) 模式进行客户端特定的聚合。适合规划领域驱动微服务边界的架构师。

返回所有模板