- Home
- Skills
- APIs & Backend
- Messaging Broker and Queue Selection
Messaging Broker and Queue Selection
Selects message brokers: log-based streams vs transient work queues, ordering, retention models, and operational fit.
$5
Works with the AI tools you already use
Messaging Broker and Queue Selection
Example session with this skill installed
Evaluate and select the messaging broker technology for our Core Retail Payment Notification & Ledger Relay Engine.
- Subject: payment-notification-relay v2.0 (run-id: banking-queue-001) dispatching transaction notifications across 22M accounts.
- Deciders: Lead Messaging Infrastructure Architect (David O'Reilly) and Head of Payment Operations (Elena Rostova).
- Workload: Sustaining peak 32,000 messages/sec; p99 broker latency <= 10 ms; strict FIFO ordering per customer account ID; 7-day replayability requirement.
- Tension: Squad proposed standard AWS SQS or RabbitMQ transient queues; David O'Reilly and Elena Rostova strictly reject SQS Standard and transient RabbitMQ, citing incident INC-4938 where SQS out-of-order delivery credited refunds before debits, while an un-replayable queue pop in RabbitMQ permanently lost 85,000 audit records during an S3 outage. They mandate an authoritative Broker Selection: log-based streaming vs work queues, partitioned FIFO ordering, persistent replay retention, and consumer group offset management.
Write the queue selection specification under docs/.
- Read your context and instructions
- Compiled the messaging broker
- Generated the document
Wrote docs/architecture/tasks/banking-queue-001/queue-selection/queue-selection-spec.md. Complete messaging broker selection specification establishing log-based append storage, partitioned FIFO ordering by account ID, 7-day replayability, and consumer group offset governance.
skill: queue-selection
Messaging Broker & Queue Selection: Payment Notification Relay [QUEUE-PAY-001]
Summary
This specification establishes the messaging broker evaluation, architectural comparison, and selection decision for payment-notification-relay v2.0 under run ID banking-queue-001. It evaluates messaging broker technologies for dispatching real-time payment notifications and ledger journal events across 22 million retail user accounts sustaining 32,000 peak messages/second. It decisively resolves the data loss and race conditions demonstrated in incident INC-4938 (where using AWS SQS Standard queues caused out-of-order message processing that applied payment refunds before debits, while transient un-replayable RabbitMQ queues permanently lost 85,000 transaction audit logs during a downstream storage hiccup). The evaluation benchmarks three primary candidates: AWS SQS (Standard & FIFO), RabbitMQ 3.13 (Quorum Queues), and
Apache Kafka 3.7 (AWS MSK). It selects Apache Kafka as the optimal messaging backbone, delivering
strict per-account FIFO partitioned ordering, an immutable
7-day append-only replay log,
at-least-once delivery with consumer offset commits, and sub-10ms publish latencies.
Detailed Description
Selecting between traditional message queues and distributed log streams represents a fundamental architectural decision. Traditional message queues (RabbitMQ, SQS) treat messages as ephemeral tasks: messages are pushed to consumers and deleted once acknowledged. Once a message is popped, historical replay is impossible, and maintaining strict FIFO ordering across parallel consumers degrades throughput catastrophically. Distributed event logs (Apache Kafka, Apache Pulsar) treat messages as an immutable, append-only chronological record. Multiple independent consumer groups read from the same partitioned log at their own pace, and historical events can be replayed repeatedly from arbitrary offsets.
Payment Event Ingress (32,000 msgs/sec)
│
▼
[ Producer: Partition Key = `account_id` (e.g. `acc_8812`) ]
│
▼ (Hash: MurmurHash2 -> Partition 14)
┌────────────────────────────────────────────────────────┐
│ Apache Kafka Cluster (`bank-payment-events-v1`) │
│ ├── 64 Partitions (Guarantees Strict FIFO per Key) │
│ ├── Append-Only Disk Log (7-Day Replay Retention) │
│ └── Multi-AZ In-Sync Replicas (`min.isr=2`, `acks=all`)│
└────────────────────────┬───────────────────────────────┘
│
┌────────────────┼────────────────┐ (Independent Consumer Groups)
▼ ▼ ▼
[ Notification Workers ] [ Ledger Replay ] [ SEC Audit Archiver ]
Consumer Group A Consumer Group B Consumer Group C
Real-Time SMS Dispatch Can Replay 7 Days Permanent S3 Cold Vault
Criteria and weights
| Criterion | Why it matters here | Weight | Source of the weight |
|---|---|---|---|
| Strict Per-Entity FIFO Ordering | Debits, holds, and credits for a given account must be processed in chronological order (INC-4938). | 0.40 | David O'Reilly (Lead Messaging Architect) |
| Historical Replayability & Retention (7 Days) | Lost audit logs or consumer bugs require rewinding consumer offsets to reprocess data. | 0.30 | Elena Rostova (Head of Payment Operations) |
| High-Throughput Write Latency (p99 <= 10 ms) | Broker must sustain 32,000 msgs/sec without queue lockups or memory thrashing. | 0.15 | Core Transaction Ingress SLA |
| Consumer Group Independence | Multiple downstream services (SMS, Ledger, Fraud) must consume the stream at independent rates. | 0.15 | Architecture Integration Charter |
Comparison
| Messaging Candidate | Ordering Model | Historical Replay | Max Throughput Ceiling | Operational Model | Evaluation |
|---|---|---|---|---|---|
| Option A: AWS SQS (Standard/FIFO) | Best-effort (Standard); 300 msg/s cap (FIFO without batch) | Zero (Messages deleted on ACK) | Low on FIFO (Bottleneck) | Serverless SaaS | Rejected: Standard caused out-of-order debits in INC-4938; FIFO cannot hit 32k TPS. |
| Option B: RabbitMQ Quorum Queues | Single-queue FIFO (Bottleneck) | Zero (Transient broker deletion) | 14,000 msgs/sec | Managed / Self-hosted | Rejected: Caused permanent loss of 85,000 logs; lacks log replayability. |
| Option C: Apache Kafka MSK (Chosen) | Partitioned FIFO by Key | 7-Day Immutable Disk Replay | 100,000+ msgs/sec | AWS Managed (MSK) | Selected: Strict account ordering, 7-day replay, 32k+ TPS, sub-10ms. |
Result
Option C is selected. Apache Kafka provides partitioned FIFO ordering by account ID, an immutable 7-day log for audit replayability, and independent consumer offset tracking.
Required Mechanisms
1. Message Workload Profile & Partition Sizing [MC-WP-01]
- Ingress Workload: Peak 32,000 messages/sec, median payload size 2.4 KB (JSON/Avro).
- Partition Cardinality: Exactly 64 partitions on topic
payment.settlement.journal.v1.
Throughput Capacity per Partition: $\frac{32,000}{64} = 500\text{ msgs/sec per partition}$ (well within Kafka's 2,500 msg/sec single-partition limit).
2. Partition Keying & Deterministic Ordering [MC-PO-01]
- Partition Key: Immutable string
account_id(e.g.acc_994102). - FIFO Ordering Invariant:
Partition = MurmurHash2(account_id) % 64
All events affecting a specific customer account route to the exact same Kafka broker partition, guaranteeing strict FIFO sequence.
3. Replay & Long-Term Retention Policy [MC-RP-01]
- Log Retention Window: Exactly 7 days (168 hours):
log.retention.hours = 168
Replay Protocol: In the event of a downstream consumer bug or database corruption, operators can rewind the consumer group offset:
kafka-consumer-groups.sh --bootstrap-server msk:9092 --group notification-workers \
--topic payment.settlement.journal.v1 --reset-offsets --to-datetime 2026-09-15T00:00:00Z --execute
4. Consumer Offsets & Dead-Letter Quarantine [MC-DL-01]
Commit Semantics: Consumers process messages and commit offsets to __consumer_offsets strictly after successful persistence (At-Least-Once delivery).
Poison Pill Quarantine: If a message fails parsing or processing after
3 retries, the consumer forwards the message to payment.settlement.journal.dlq and commits the offset, preventing partition blocking.
Invariants and Contracts
Strict Entity-Keyed Partition Invariant [INV-QUEUE-01]
Events modifying stateful accounts must declare the `account_id` as the message partition key.
Publishing balance-altering messages with null or random partition keys is strictly prohibited.
Seven-Day Immutable Log Retention [INV-QUEUE-02]
The payment event broker must enforce a minimum immutable disk retention period of seven days.
Deploying ephemeral queues that delete messages immediately upon consumer acknowledgment is barred.
At-Least-Once Consumer Offset Commit [INV-QUEUE-03]
Consumer workers must commit Kafka offsets only after downstream business transactions have successfully committed.
Auto-commit (`enable.auto.commit = true`) is strictly prohibited on financial ledger topics.
Explicit Unknowns
- AWS MSK cross-AZ network transit cost under sustained 32,000 msgs/sec when consumers reside in alternative availability zones (G-1).
- Kafka consumer group rebalance duration when consumer worker pods scale horizontally from 16 to 64 instances (G-2).
Traceability
| Claim | Classification | Source | Freshness |
|---|---|---|---|
| 22 million retail user accounts | provided | Business scope intake | Current |
| Peak 32,000 messages/sec | provided | Volumetric traffic profile | Current |
| Incident INC-4938 out-of-order & lost audit logs | provided | Historical post-mortem record | Historical |
| 7-day replayability requirement | provided | Financial Regulatory Audit Mandate | Current |
| Latency budget p99 <= 10 ms | provided | Core Banking SLA | Current |
| Apache Kafka (AWS MSK) selected | decided | David O'Reilly & Elena Rostova | 2026-09-15 |
| Strict account_id partition keying | decided | Architectural invariant INV-QUEUE-01 | 2026-09-15 |
Verification
No validator was supplied, so no command was run.
Reviewer self-check against queue selection standards:
- Ordering Rigor: PASS. MurmurHash2 on
account_idguarantees FIFO sequencing; eliminates INC-4938 race. - Replay Safety: PASS. 7-day disk retention allows full consumer offset rewinds.
- Throughput Scaling: PASS. 64 partitions easily absorb 32,000 TPS with sub-10ms publish latency.
- Markdown Hygiene: PASS. Native Markdown syntax strictly adheres to
rule_markdown.md.
Open Decisions
DEC-QUEUE-01: David O'Reilly to determine whether Kafka Tiered Storage (S3 offloading) should be enabled to extend audit retention from 7 days to 90 days at low storage cost (Owner: David O'Reilly).
Next steps
- Infrastructure team provisions 64-partition MSK cluster with AWS Graviton3 brokers via Terraform.
- Core Payment team configures Kafka producer libraries with
acks=alland MurmurHash2 account keying. - Conduct staging resilience drill simulating consumer offset rewind to verify 100% accurate replay of 100,000 past transactions.
messaging-broker-and-queue-selection.pdf
PDF · document
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
What it does
This skill selects among identified messaging broker/task-queue products for accepted asynchronous interaction and topology contracts. It compares candidates under equivalent message, workload, delivery, retention, failure and operating conditions.
Use it when
Use when event-driven/messaging owners have supplied bounded interaction semantics and an authorized decision needs one broker/product, bounded stack/shortlist or defer result from current comparable evidence.
For example: “We need a queue for order events. The team wants Kafka because it's what everyone uses, but we have 200 messages a minute and no platform engineer.”
What you get
- Queue Selection Report
Written as Markdown to <your output folder>/architecture/tasks/<run-id>/queue-selection/.
What it will not do
Do not use for messaging architecture, queue/pub-sub/log/workflow choice, message/schema/protocol design, topic/partition/routing/DLQ configuration, worker design, tuning, provisioning or implementation.
How it works
- Check messaging is the right integration.
- State the ordering requirement precisely.
- State the delivery guarantee you need and can afford.
- Fix retention and replay.
- Weigh operability and the managed options honestly.
- Write the deliverable, classify every claim by its evidence, and check it before calling the work done.
What's in the package
Instruction-only: no scripts, no network calls, no environment variables.
- LICENSE.txt
- SKILL.md
- agents/openai.yaml
- assets/output-template-task.md
- references/domain-rules.md
- references/operating-rules.md
- references/output-contract.md
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 12 days ago
- Passed all security checks, Safe to install