
Akka Hosting Actor Patterns
This is a solid architectural pattern for building Akka.NET entity actors that work identically in unit tests and production. The key insight is using GenericChildPerEntityParent to mimic cluster sharding semantics locally, so you write your actor once and swap execution modes via configuration. The message extractor pattern keeps routing logic consistent whether you're running locally or in a real cluster. The Akka.Hosting extension methods are clean and the ITimeProvider abstraction solves the DateTime.Now testing problem elegantly. If you're building domain entities with Akka and tired of maintaining separate test and production actor setups, this pattern saves real work.
- skills.sh installs
- 434
- GitHub stars
- 1.3K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add aaronontheweb/dotnet-skills --skill akka-hosting-actor-patterns --agent claude-codeInstalls into .claude/skills of the current project.
Files
Akka.Hosting Actor Patterns
When to Use This Skill
Use this skill when:
- Building entity actors that represent domain objects (users, orders, invoices, etc.)
- Need actors that work in both unit tests (no clustering) and production (cluster sharding)
- Setting up scheduled tasks with akka-reminders
- Registering actors with Akka.Hosting extension methods
- Creating reusable actor configuration patterns
Core Principles
- Execution Mode Abstraction - Same actor code runs locally (tests) or clustered (production)
- GenericChildPerEntityParent for Local - Mimics sharding semantics without cluster overhead
- Message Extractors for Routing - Reuse Akka.Cluster.Sharding's IMessageExtractor interface
- Akka.Hosting Extension Methods - Fluent configuration that composes well
- ITimeProvider for Testability - Use ActorSystem.Scheduler instead of DateTime.Now
Execution Modes
Define an enum to control actor behavior:
Sponsors
Details
- Repository
- github.com/aaronontheweb/dotnet-skills
- Categories
- Testing & QA, .NET & C#
- First seen
- Jun 3, 2026
More from aaronontheweb/dotnet-skills
All 34- Akka Net Testing Patterns431
- OpenTelemetry NET Instrumentation431
- Akka Net Management430
- Akka Net Aspire Configuration415
- Marketplace Publishing408
- Modern Csharp Coding Standards2.3K
- Csharp Concurrency Patterns1.6K
- Efcore Patterns1.6K
- Dependency Injection Patterns703
- Database Performance700
- Dotnet Project Structure692
- Api Design690
- Type Design Performance684
- Ilspy Decompile640
- Package Management613
- Microsoft Extensions Configuration609
- Serialization596
- Crap Analysis581
- Dotnet Slopwatch580
- Testcontainers Integration Tests579
- Playwright Blazor Testing560
- Dotnet Local Tools550
- Aspire Integration Testing522
- Mjml Email Templates513