This project is a practice-oriented simulation designed to demonstrate the implementation of resilient communication patterns in backend services using .NET and Polly.
The goal is to simulate how notification systems (e.g., Email, SMS, Push) can remain robust under failure, using resilience techniques such as:
- Retry (in case of transient failures)
- Timeout (to avoid hanging operations)
- Circuit Breaker (to stop calling unstable services)
- Fallback strategies (alternative communication channels)
📌 This project is not meant for production – it's a focused training tool to understand key backend resilience concepts and fault-handling strategies.
Retry: retries failed sends with exponential backoffTimeout: enforces maximum execution time per providerCircuit Breaker: temporarily disables unstable sendersWrap: combines all policies together for layered protection
- Dispatches notifications to multiple providers
- Supports fallbacks when primary channels fail
- Randomized failure simulation to trigger Polly behaviors
- Supports multiple channels:
- SMS
- Push
- Each implements a common
ISenderinterface
- Providers are injected with their policies
- Policy is shared but abstracted for better testability
- Logs retries, failures, fallbacks and successes
- Easily customizable and high-performance
- Run the project:
dotnet run
- Send a POST request using Postman or an .http file
POST http://localhost:{port}/api/notification
{
"receiver": "hossein@example.com",
"message": "Hello world!",
"methods": [ 0, 1 ],
"fallbacks": [ 2 ]
}- Check for Logs
📦 Project Structure
resilience-notification-practice/
├── API/
│ └── NotificationEndpoints.cs
├── Core/
│ ├── Dispatchers/
│ ├── Interfaces/
│ │ └── ISender.cs
│ ├── Models/
│ │ ├── Enums/
│ │ └── NotificationRequest.cs
│ ├── Senders/
│ │ ├── Email/
│ │ ├── Sms/
│ │ └── Push/
│ └── Services/
│ └── NotificationSenderResolver.cs
├── DTOs/
│ ├── Requests/
│ └── Responses/
├── Infrastructure/
│ ├── Log/
│ │ └── NotificationLogTemplate.cs
│ └── Resilience/
│ └── NotificationPollyPolicies.cs