Orchestrix.Mediator 1.0.0

dotnet add package Orchestrix.Mediator --version 1.0.0
                    
NuGet\Install-Package Orchestrix.Mediator -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Orchestrix.Mediator" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Orchestrix.Mediator" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Orchestrix.Mediator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Orchestrix.Mediator --version 1.0.0
                    
#r "nuget: Orchestrix.Mediator, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Orchestrix.Mediator@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Orchestrix.Mediator&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Orchestrix.Mediator&version=1.0.0
                    
Install as a Cake Tool

<p align="center"> <img src="logo.png" alt="Orchestrix.Mediator Logo" width="1024" /> </p>

๐Ÿฆ– Orchestrix.Mediator

Modern, extensible, and production-grade mediator engine for .NET 8+
With parallel notifications, streaming, pipelines, source generators, and full CQRS support via extensions.

โœจ Why Orchestrix.Mediator?

Orchestrix.Mediator is a complete rethinking of a mediator engine for the modern .NET ecosystem.

โœ… Reflection-based dispatch by default
๐Ÿงฌ Source generator dispatch (opt-in)
๐Ÿ“ข Sequential & parallel notifications
๐Ÿ“ก Streaming request handling (IAsyncEnumerable<T>)
๐Ÿงฑ Fully pluggable via pipelines and diagnostics hooks
๐Ÿงฉ CQRS-style ICommand, IQuery, and handler support (extension)
๐Ÿ”ง Minimal API & Controller friendly
๐Ÿงช Built for performance and testability


Full Documentation: Orchestrix.Mediator Docs โ†’


๐Ÿ“ฆ Installation

dotnet add package Orchestrix.Mediator

Optional Extensions

# Optional: Source generator-based dispatch
dotnet add package Orchestrix.Mediator.SourceGenerators

# Optional: CQRS abstractions (ICommand, IQuery, etc.)
dotnet add package Orchestrix.Mediator.Cqrs

๐Ÿงฐ Basic Example โ€“ Core Only

๐Ÿงพ Define a request, notification, and handlers:

public record TestCommand(string? Name, string? Surname, string? Email, string? Phone) : IRequest<string>;

public class TestCommandHandler(IPublisher publisher) : IRequestHandler<TestCommand, string>
{
    public async ValueTask<string> Handle(TestCommand request, CancellationToken cancellationToken)
    {
        Console.WriteLine($"Hello {request.Name} {request.Surname} {request.Email} {request.Phone}");
        
        await publisher.Publish(new TestNotification(request.Name), cancellationToken);
        return "OK";
    }
}

public record TestNotification(string? Name) : INotification;

public class LogTestNotificationHandler : INotificationHandler<TestNotification>
{
    public ValueTask Handle(TestNotification notification, CancellationToken cancellationToken)
    {
        Console.WriteLine($"[Generic Handler] Logging TestNotification: {notification.Name}");
        return default;
    }
}

public class ParallelTestNotificationHandler : IParallelNotificationHandler<TestNotification>
{
    public async ValueTask Handle(TestNotification notification, CancellationToken cancellationToken)
    {
        Console.WriteLine($"[Parallel Handler] Simulating async work for {notification.Name}");
        await Task.Delay(300, cancellationToken);
    }
}

โš™๏ธ Minimal API / Controller Example

[HttpGet]
public async Task<IActionResult> Test([FromServices] ISender sender)
{
    var command = new TestCommand("Mohammad", "Anzawi", "anzawi@test.com", "00000");
    var result = await sender.Send(command, CancellationToken.None);
    return Ok(result);
}

๐Ÿ”ง Configuration

Default (Reflection-based):

services.AddOrchestrix(cfg => cfg.RegisterHandlersFromAssemblies(typeof(SomeHandler).Assembly));

Enable Source Generator (opt-in):

services.AddOrchestrix(cfg => 
{
    cfg.UseSourceGenerator() // add this line
    .RegisterHandlersFromAssemblies(typeof(SomeHandler).Assembly);
});

๐Ÿงฌ Dispatch Modes

Mode Description
๐Ÿชž Reflection Resolves via IServiceProvider
โšก Source Generator Compile-time dispatch, AOT safe

Source generators eliminate runtime lookup and boost performance.
See Source Generators โ†’


โœ… Core Interfaces

Interface Role
IRequest, IRequest<T> Request contracts
INotification Fire-and-forget events
ISender, IPublisher, IMediator Dispatch interfaces
IRequestHandler<T>, IRequestHandler<T, R> Request handlers
INotificationHandler<T>, IParallelNotificationHandler<T> Event handlers
IStreamRequest<T>, IStreamRequestHandler<T, R> Async streaming support
IPipelineBehavior<T, R> Pipeline behaviors
VoidMarker (internal) Used internally to support IRequest (non-generic) in source-generated dispatch

๐Ÿง  Diagnostics & Hooks

Interface Role
ISendHook, IPublishHook, IStreamHook Lifecycle instrumentation
IHookExecutor, HookConfiguration Hook orchestration & control

Enable diagnostics, logging, tracing, or global behaviors with zero impact on business logic.
See Hooks & Pipelines โ†’


๐Ÿงญ CQRS Extension

Install:

dotnet add package Orchestrix.Mediator.Cqrs

Adds:

// Marker interfaces
ICommand, ICommand<TResponse>
IQuery<TResponse>

// Handlers
ICommandHandler<T>, ICommandHandler<T, R>
IQueryHandler<T, R>

Supports both:

public class SaveCommand : ICommand;         // No return
public class SaveCommand : ICommand<Unit>;   // Explicit unit

See CQRS Guide โ†’


๐Ÿ“š Documentation Index

Full Documentation: Orchestrix.Mediator Docs โ†’

Topic Description
๐Ÿ Getting Started Install, configure, send, publish
๐Ÿง  Core Concepts Interfaces, dispatcher roles
๐Ÿงญ CQRS Guide ICommand, IQuery, etc.
โœจ Source Generators Compile-time dispatching
๐Ÿช Hooks & Pipelines Diagnostics + middleware
๐Ÿ“ก Streaming Streaming requests
๐Ÿ“ข Notifications Publish, parallelism
๐Ÿ” Diagnostics Tracing, hook config
๐ŸŒ€ Sagas Guide Add in-process Sagas
๐Ÿง™ Advanced Usage TrySend, TryPublish, fallback
๐Ÿ“– API Reference Interface + type index
โ“ FAQ Answers to common Qs
๐Ÿ” Migration Guide From MediatR to Orchestrix

๐Ÿ” Migrating from MediatR?

See MIGRATION.md

  • Swap IMediator to ISender and IPublisher
  • Replace IRequestHandler<> with ICommandHandler<> / IQueryHandler<>
  • Replace INotificationHandler<> with IParallelNotificationHandler<> if parallel behavior is needed
  • Enable MediatorMode.SourceGenerator for performance
  • Use Dispatch, DispatchVoid, TrySend, TryPublish, etc.

๐Ÿš€ Performance-Ready

โšก Zero-reflection dispatch via source generators
๐Ÿงต True parallel notifications
โœ… ValueTask everywhere
๐Ÿงฌ NativeAOT-friendly
๐Ÿ”ง Small, fast, testable core


๐Ÿ“œ License

MIT โ€” free for personal and commercial use.


๐Ÿ™ Acknowledgements

Inspired by MediatR
Rebuilt from scratch for modern .NET by @anzawi
Proudly open-source and forever free

๐Ÿฆ– Orchestrix.Mediator: Mediation, Modernized.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Orchestrix.Mediator:

Package Downloads
Orchestrix.Mediator.Cqrs

Orchestrix.Mediator.Cqrs adds clean CQRS-style base abstractions for commands and queries to the Orchestrix.Mediator mediator library. Designed for vertical slice architectures and CQS-based separation of concerns.

Orchestrix.Mediator.Sagas

Fluent, in-process saga orchestration engine for Orchestrix.Mediator โ€” with step retries, compensation, timeout, hooks, and decorators.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 349 7/20/2025