Skip to content

NetFabric/intelligentium / plugins/dotnet/.apm/skills/dotnet-channels

dotnet-channels

Verified

Design, implement, debug, test, and review in-process producer-consumer pipelines with System.Threading.Channels. USE FOR: Channel<T>, ChannelReader<T>, ChannelWriter<T>, bounded/unbounded queues, BoundedChannelFullMode, backpressure, TryWrite, WriteAsync, ReadAsync, ReadAllAsync, completion, cancellation, concurrent producers/consumers, BackgroundService workers, in-memory event queues, overload protection, and channel performance. DO NOT USE FOR: durable or cross-process messaging, distributed pub/sub, broker delivery guarantees, Rx.NET stream composition, task-parallel dataflow blocks, or simple thread-safe collections with no asynchronous producer-consumer requirement.

references/in-memory-messaging-boundaries.md

View on GitHub
# In-Memory Messaging Boundaries

## Valid Uses

- Decouple modules inside one process.
- Queue bounded background work after the initiating request has decided its own result.
- Serialize non-thread-safe processing or limit expensive concurrent work.
- Coalesce best-effort state updates when the newest value matters more than history.

## Not A Durable Broker

| Requirement | Use Instead Of Only A Channel |
| --- | --- |
| Survive process restart/crash | Durable queue, transactional outbox, or persisted job store |
| Cross process/machine delivery | Message broker or transport-backed queue |
| At-least-once/exactly-once semantics | Durable transport plus idempotency and deduplication design |
| Independent subscriber fan-out | Topic/pub-sub transport or separate managed queues |
| Operations replay/audit | Persistent event log or queue |

Channels deliver in memory only. A successful `WriteAsync` means the item entered the current process's queue, not that a consumer completed it or that it will survive a failure.

## In-Memory Event Bus

- Keep the public contract at the domain/event abstraction, not `Channel<T>`.
- Use a bounded queue when producers are request paths. Decide whether overload awaits, rejects, coalesces, or drops each event category.
- Create a DI scope for each event handler dispatch if handlers use scoped services.
- Add idempotency, retries, error recording, and observability before using it for meaningful side effects.
- Replace the channel with a durable boundary before splitting the process or requiring recovery guarantees. Do not present an in-memory queue as reliable integration messaging.

## Sources

- [Lightweight in-memory message bus](https://milanjovanovic.tech/blog/lightweight-in-memory-message-bus-using-dotnet-channels)
- [Channels](https://learn.microsoft.com/dotnet/core/extensions/channels)
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall