notification-handlers

Dispatch domain events via MediatR notification handlers after commit.

4|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill notification-handlers
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: notification-handlers
Source: https://github.com/FaysilAlshareef/dotnet-ai-kit/tree/main/skills/cqrs/notification-handlers
Command: npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill notification-handlers

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Coordinating multiple reactions to a single domain event can be error-prone without a structured pattern. MediatR notification handlers let you attach several independent responders to the same event, ensuring consistent side effects.

Core Features & Use Cases

  • Supports multiple INotificationHandler implementations for a single domain event to enable parallel or sequential handling
  • Dispatches events after successful persistence to maintain data integrity and avoid partial updates
  • Includes guidance for implementing an interceptor-based dispatcher to publish domain events automatically

Quick Start

Define domain events on your aggregates, register the handlers, and dispatch them after saving changes.

Frequently Asked Questions about notification-handlers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I dispatch domain events using MediatR after saving changes?

MediatR notification handlers dispatch domain events after successful persistence to trigger multiple independent responders. This ensures consistent side effects like emails, analytics, and audit trails without risking partial updates from failed database transactions.

How do I trigger multiple handlers for a single domain event in CQRS?

Trigger multiple handlers for a single domain event by implementing several INotificationHandler implementations for the same event. MediatR supports parallel or sequential execution of these independent responders to coordinate consistent reactions across your system.

Why dispatch domain events after saving changes instead of before?

Dispatching domain events after saving changes maintains data integrity and avoids partial updates. If events fire before persistence and the transaction fails, downstream side effects like emails or analytics would react to data that does not exist.

How do I make MediatR notification handlers idempotent for domain events?

Make MediatR notification handlers idempotent by using a domain event base type and a post-commit publisher designed for reliability. This pattern ensures that duplicate event processing does not cause repeated side effects like duplicate audit trails or analytics entries.

Can I use MediatR notifications for cross-service side effects like audit trails?

Yes, MediatR notifications support cross-service side effects such as emails, analytics, and audit trails by attaching multiple independent responders to a single domain event within a domain-driven design architecture.

What is the best way to automatically publish domain events in a domain-driven design?

Automatically publish domain events in a domain-driven design by implementing an interceptor-based dispatcher. This pattern automatically dispatches events defined on your aggregates through MediatR after changes are successfully saved.