Skip to content
Back to skills

Messaging Patterns

ASecurity

Designs .NET broker consumers, producers, background processing, idempotency, outbox/inbox, bounded retries, dead-lettering, and graceful shutdown. Use when message delivery semantics matter; do not use for in-process async queues only (use async-concurrency).

  • 7 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentsazuretestingdatabase

Works with

  • cli

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add k4ndev/claude-code-dotnet --skill messaging-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Messaging Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Messaging Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/k4ndev-messaging-patterns/badge)](https://www.skillsdirectory.com/skills/k4ndev-messaging-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: messaging-patterns
description: Designs .NET broker consumers, producers, background processing, idempotency, outbox/inbox, bounded retries, dead-lettering, and graceful shutdown. Use when message delivery semantics matter; do not use for in-process async queues only (use async-concurrency).
---

# Messaging Patterns

## Purpose
Make asynchronous message processing reliable under redelivery, partial failure, deployment, and shutdown.

## Scope
Broker delivery/acknowledgment, message contracts, consumer concurrency, outbox/inbox, idempotency, retries, dead-letter handling, and hosted consumers.

## When to use
- A system uses RabbitMQ, Kafka, Azure Service Bus, MassTransit, Rebus, Wolverine, or another broker.
- User asks about duplicate delivery, dual writes, ordering, poison messages, or consumer recovery.

## Do not use for
- Process-local `Channel<T>`/task coordination without broker semantics: use `async-concurrency`.
- General background hosted service with no messaging: use `aspnetcore-patterns` or `async-concurrency`.
- Broker runtime incident collection: use `dotnet-diagnostics`.

## Required context
Identify broker/client versions, delivery guarantee and acknowledgment timing, transaction support, message identity/schema, side effects, concurrency/prefetch, retry/DLQ topology, deployment, and shutdown timeout.

## Workflow
1. Trace publish -> broker persistence -> delivery -> handler side effect -> acknowledgment; document crash windows.
2. Assume at-least-once delivery unless a precise broker configuration proves otherwise; design side effects idempotently by stable message/business identity.
3. For atomic database state + publication, use a transactional outbox and relay; consumers may use inbox/dedup within their DB transaction.
4. Separate transient from permanent failures; bound attempts/backoff and avoid retry storms. Route poison messages to monitored dead-letter storage with replay ownership.
5. Bound prefetch, consumer concurrency, payload size, and in-flight work; state ordering guarantees/partition key requirements.
6. Version message contracts additively; coordinate incompatible changes with producer/consumer rollout.
7. During shutdown stop accepting new deliveries, settle/finish in-flight work within host limits, and make redelivery safe.
8. Test duplicate delivery, crash-before-ack, transient/permanent failure, DLQ replay, contract evolution, and graceful stop.

## Decision rules
- Exactly-once broker delivery does not guarantee exactly-once business effects across external systems.
- Never hold a database transaction open while waiting on remote broker I/O unless the design explicitly requires and supports it.
- Use a process-local bounded channel only when durability across process loss is not required.

## Expected output format
Provide delivery timeline, crash-window analysis, idempotency/outbox strategy, retry/DLQ limits, ordering/concurrency assumptions, shutdown plan, and failure-injection tests.

## Common mistakes
- Acknowledging before durable effects, unbounded retries/prefetch, database-plus-broker dual write, or assuming a retry policy makes handlers idempotent.

## Edge cases
- Outbox relays can publish twice if they crash before marking sent; downstream idempotency remains necessary.
- Message TTL/retention and schema compatibility differ by broker; verify configured semantics.
- Cancellation during a committed side effect can trigger redelivery; use dedupe rather than treating cancellation as rollback.

## Examples
See [messaging examples](examples.md) for an outbox row and idempotent consumer transaction.

## Test scenarios
- Positive: “An order commits but RabbitMQ publish fails; design reliable delivery and duplicate-safe consumer.”
- Negative: “A local worker queue needs backpressure but no persistence” routes to `async-concurrency`.
- Boundary: “Diagnose consumer lag from runtime traces and counters” selects `dotnet-diagnostics`; broker delivery design remains this skill.

## Related skills
`async-concurrency`, `dotnet-diagnostics`, `logging-observability`, `efcore-patterns`, `testing-quality`.

Files in this skill

  • SKILL.md4 KB
  • examples.md2.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.