360 Secure SkillHub
360 安全技能中心

Message Queues

这是消息队列深度落地工作流技能,核心通过6阶段(交付语义、拓扑分区、消息契约、消费重试、运维扩容、故障演练),指导消息队列选型、语义定义、容错设计、运维监控全流程。典型场景含Kafka/RabbitMQ选型对比、消费延迟、死信增长、幂等性需求对齐等,输入需确认云环境与排序要求,输出明确的落地文档及检查清单。

clawkk
clawkk
热度 45.89
最近更新 2026-05-11 17:36:11
分类:开发依赖:纯提示词应用场景:调试排错 / API 集成 / DevOps / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add message-queues
Metadata
name
message-queues
description
Deep message queue workflow—queue vs topic, ordering and partitions, retries and DLQ, idempotency, backpressure, observability, and failure design. Use when integrating workers, event buses, or debugging poison messages and lag.

Message Queues (Deep Workflow)

Queues decouple producers and consumers—and introduce duplicates, ordering surprises, poison messages, and lag. Make delivery semantics and failure handling explicit.

When to Offer This Workflow

Trigger conditions:

  • Choosing Kafka vs RabbitMQ vs SQS vs Pub/Sub
  • Consumer lag, DLQ growth, reprocessing needs
  • “Exactly-once” expectations—need alignment on reality

Initial offer:

Use six stages: (1) delivery semantics, (2) topology & partitions, (3) message contract, (4) consumers & retries, (5) ops & scaling, (6) failure drills). Confirm cloud and ordering requirements.


Stage 1: Delivery Semantics

Goal: Choose at-most-once, at-least-once, or effective-once via idempotency.

Questions

  1. Can duplicate processing break invariants?
  2. Is ordering global, per-entity, or unnecessary?
  3. Latency vs durability trade-offs

Exit condition: One paragraph per pipeline stating semantics.


Stage 2: Topology & Partitions

Goal: Throughput and ordering align—ordering only within partition when using Kafka-style partitions.

Practices

  • Partition key often equals business key (e.g., user id)
  • Watch hot partitions

Stage 3: Message Contract

Goal: Versioned events or commands with schema registry.

Practices

  • Envelope: id, type, version, timestamp
  • Payload size limits; reference blobs by id

Stage 4: Consumers & Retries

Goal: Exponential backoff + jitter; DLQ with reason; replay tooling owned.

Pitfalls

  • Retries can reorder unless single-threaded per partition

Stage 5: Ops & Scaling

Goal: Lag metrics, consumer offset health, rebalance awareness (Kafka).


Stage 6: Failure Drills

Goal: Kill consumer mid-batch; duplicate publish intentionally; validate idempotency.


Final Review Checklist

  • Delivery semantics and idempotency explicit
  • Partitioning/ordering strategy documented
  • Versioned message contract
  • Retry, DLQ, replay documented
  • Lag metrics and alerts; capacity plan

Tips for Effective Guidance

  • Exactly-once end-to-end is rare—design for at-least-once + idempotent handlers.
  • Challenge global ordering requirements—they cost scale.
  • Visibility timeouts (SQS) differ by product—read the vendor docs.

Handling Deviations

  • Transactional outbox when you need DB + queue consistency without dual writes.