An open API service indexing awesome lists of open source software.

https://github.com/mreshboboyev/notifications-channel

Notifications.Channel is an asynchronous notification system built with .NET 9, MediatR, and OpenTelemetry. It uses channel-based publishers for efficient, non-blocking event processing, ensuring scalability, observability, and real-time notifications in distributed applications.
https://github.com/mreshboboyev/notifications-channel

asyncronous-messaging background-processing channels cloud-native docker event-driven-architecture event-handling logging mediatr microservices notifications observability open-telemetry pub-sub tracing

Last synced: 3 months ago
JSON representation

Notifications.Channel is an asynchronous notification system built with .NET 9, MediatR, and OpenTelemetry. It uses channel-based publishers for efficient, non-blocking event processing, ensuring scalability, observability, and real-time notifications in distributed applications.

Awesome Lists containing this project

README

        

# ๐Ÿ”” Notifications.Channel โ€“ Scalable Asynchronous Notifications in .NET 9 ๐Ÿš€

![.NET 9](https://img.shields.io/badge/.NET%209-blue?style=for-the-badge)
![MediatR](https://img.shields.io/badge/MediatR-%E2%9C%85-green?style=for-the-badge)
![OpenTelemetry](https://img.shields.io/badge/OpenTelemetry-%F0%9F%94%A5-orange?style=for-the-badge)
![Asynchronous Messaging](https://img.shields.io/badge/Async%20Messaging-%F0%9F%9A%80-purple?style=for-the-badge)
![Docker](https://img.shields.io/badge/Docker-%F0%9F%90%A6-blue?style=for-the-badge)

## ๐ŸŽฏ Overview

**Notifications.Channel** is a **high-performance, asynchronous notification system** built with **.NET 9**, **MediatR**, and **OpenTelemetry**. This solution provides **event-driven messaging** using a **custom channel-based publisher**, ensuring **scalability, reliability, and observability** for real-time notifications.

> **Why Use Notifications.Channel?**
> - ๐Ÿš€ **Asynchronous & Non-Blocking** โ€“ Uses **channels for efficient notification handling**.
> - ๐Ÿ“ก **Event-Driven Design** โ€“ Implements **MediatR for pub/sub messaging**.
> - ๐Ÿ”Ž **Built-in Observability** โ€“ Integrated with **OpenTelemetry** for tracing.
> - ๐Ÿ›  **Docker-Ready & Scalable** โ€“ Deployable in **containerized environments**.

---

## ๐ŸŒŸ Features

โœ… **.NET 9 Web API** โ€“ Built with the latest **ASP.NET Core framework**.
โœ… **MediatR Integration** โ€“ Implements **publish-subscribe (pub/sub) messaging**.
โœ… **Channel-Based Notifications** โ€“ Uses **custom channel publishers** for async handling.
โœ… **Multiple Notification Handlers** โ€“ Supports **parallel processing**.
โœ… **OpenTelemetry Tracing** โ€“ Provides **real-time observability**.
โœ… **Docker Support** โ€“ Easily deploy with **Docker containers**.

---

## ๐Ÿ—๏ธ Architecture & Project Structure

๐Ÿ“Œ **src/Notifications.Channel/Program.cs** โ€“ Configures **MediatR, OpenTelemetry**, and API setup.
๐Ÿ“Œ **src/Notifications.Channel/ChannelPublisher.cs** โ€“ Implements the **custom channel-based publisher**.
๐Ÿ“Œ **src/Notifications.Channel/OrderCreatedNotification.cs** โ€“ Defines the **notification event**.
๐Ÿ“Œ **src/Notifications.Channel/NotificationHandlers/** โ€“ Contains **async notification handlers**.

---

## ๐Ÿš€ Getting Started

### **๐Ÿ“Œ Prerequisites**
โœ… [.NET 9 SDK](https://dotnet.microsoft.com/download/dotnet/9.0)
โœ… [Docker](https://www.docker.com/) (optional for containerization)

### **Step 1: Clone the Repository**
```bash
git clone https://github.com/yourusername/Notifications.Channel.git
cd Notifications.Channel
```

### **Step 2: Build & Run the Application**
```bash
dotnet build
dotnet run --project src/Notifications.Channel
```

---

## ๐Ÿณ Running with Docker

### **Step 1: Build Docker Image**
```bash
docker build -t notifications-channel .
```

### **Step 2: Run Container**
```bash
docker run -p 8080:80 notifications-channel
```

> ๐Ÿ”น **Docker allows easy deployment** in **cloud environments** or **microservices architectures**.

---

## ๐ŸŒ API Endpoints

| Method | Endpoint | Description |
|--------|-----------|-------------|
| **POST** | `/orders` | Creates a new order & triggers **OrderCreatedNotification** |

### **Example Request (cURL)**
```bash
curl -X POST http://localhost:8080/orders
```

> ๐Ÿ“ข **When a new order is created**, the API **publishes an event** that triggers **multiple handlers** asynchronously.

---

## ๐Ÿ”Ž OpenTelemetry Integration

This project is **pre-configured with OpenTelemetry** for **end-to-end tracing**, providing **real-time monitoring** of notifications.

๐Ÿ”น **Features**:
โœ… **ASP.NET Core Instrumentation** โ€“ Captures **request-response tracing**.
โœ… **OTLP Exporter** โ€“ Sends telemetry data to **external observability platforms**.
โœ… **Real-Time Monitoring** โ€“ View **end-to-end tracing** of notifications.

---

## ๐Ÿ“จ MediatR & Asynchronous Notifications

### **How Notifications Work**

1๏ธโƒฃ **Client sends a POST request to `/orders`**.
2๏ธโƒฃ **MediatR publishes an `OrderCreatedNotification` event**.
3๏ธโƒฃ **ChannelPublisher asynchronously processes notifications**.
4๏ธโƒฃ **Multiple handlers consume the notification in parallel**.

### **Notification Handlers**

๐Ÿ”น **OrderCreatedHandler** โ€“ Logs **order creation event**.
๐Ÿ”น **SlowOrderCreatedHandler** โ€“ Simulates a **delayed event handler**.
๐Ÿ”น **VerySlowOrderCreatedHandler** โ€“ Simulates a **long-running task**.

> โšก **Handlers process events independently** without blocking the main request.

---

## ๐Ÿงช Testing

### **Unit Tests**
Run tests to verify **notification handling and performance**:
```bash
dotnet test
```

### **Manual API Testing**
๐Ÿ“Œ **Use Postman or Swagger UI** to:
โœ… **Create an order** โ†’ `/orders`
โœ… **Check OpenTelemetry traces**
โœ… **Verify async notification handling**

---

## ๐ŸŽฏ Why Use This Project?

โœ… **High-Performance Asynchronous Notifications** โ€“ Reduces **blocking operations**.
โœ… **Scalable & Fault-Tolerant** โ€“ Uses **channels & MediatR** for parallel execution.
โœ… **Full Observability with OpenTelemetry** โ€“ Provides **tracing & monitoring**.
โœ… **Production-Ready & Docker-Deployable** โ€“ Easily **scales in microservices**.

---

## ๐Ÿ“œ License

This project is licensed under the **MIT License**. See [LICENSE](LICENSE) for details.

---

## ๐Ÿ“ž Contact

For feedback, contributions, or questions:
๐Ÿ“ง **Email**: [email protected]
๐Ÿ’ป **GitHub**: [MrEshboboyev](https://github.com/MrEshboboyev)

---

๐Ÿš€ **Build scalable, event-driven APIs with Notifications.Channel!** Clone the repo & start now!