Faster.Messagebus 0.0.8

dotnet add package Faster.Messagebus --version 0.0.8
                    
NuGet\Install-Package Faster.Messagebus -Version 0.0.8
                    
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="Faster.Messagebus" Version="0.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Faster.Messagebus" Version="0.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Faster.Messagebus" />
                    
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 Faster.Messagebus --version 0.0.8
                    
#r "nuget: Faster.Messagebus, 0.0.8"
                    
#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 Faster.Messagebus@0.0.8
                    
#: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=Faster.Messagebus&version=0.0.8
                    
Install as a Cake Addin
#tool nuget:?package=Faster.Messagebus&version=0.0.8
                    
Install as a Cake Tool

🚀 Faster.MessageBus

Work in Progress License

Faster.MessageBus is a high-performance, decentralized message bus for .NET, built on NetMQ.
It enables services to form a self-organizing, self-healing peer-to-peer mesh network — with no central broker required.

⚠️ Note: This project is currently under active development and should be considered experimental.
The API may evolve before stable release.


✨ Key Features

  • Ultra-Fast Messaging — Zero-copy serialization and minimal allocations using Span<T> and ArrayPool<T>.
  • 🧩 Event & Command Dispatchers — Unified APIs for fire-and-forget events and request-reply commands.
  • 🧭 Smart Routing Mechanism — Route messages locally, within a machine, across a cluster, or network-wide, even to specific applications.
  • 🔁 Fluent Builder API — Configure timeouts, cancellation, and error handlers with clean, chainable syntax.
  • 🔍 Automatic Discovery — Nodes automatically find each other and form a distributed mesh network.
  • ❤️ Heartbeat Monitoring — Tracks node health and removes disconnected peers automatically.
  • 🔒 Thread-Safe Core — Dedicated internal scheduler eliminates the need for locking in user code.
  • 📦 Compact Serialization — Uses MessagePack + LZ4 for extremely fast and small payloads.

🧠 Core Architecture

Faster.MessageBus is a brokerless distributed messaging system for .NET.
Each application node acts as both publisher and subscriber, forming a mesh topology via NetMQ.

This allows:

  • Event broadcasting (publish/subscribe)
  • Command dispatching (request/reply)
  • Scatter-gather communication
  • Directed messaging to specific peers or groups

All of this happens without a central broker, giving you maximum speed, fault tolerance, and zero configuration overhead.


🧭 Intelligent Routing System

Faster.MessageBus introduces a 4-tier routing system, giving you full control over where and how messages travel.

Scope Description Typical Use Case
🧩 Local Executes within the same process In-memory testing or modular apps
🖥️ Machine Routes messages to all peers on the same host Multi-process systems on a single server
🌐 Cluster Sends messages to all nodes within a logical service cluster Microservice clusters, load-balanced systems
🌍 Network Broadcasts across all reachable nodes in the mesh Cross-machine, cross-network event distribution

Additionally, messages can target specific applications directly using:

.SendToAsync("app-name", command, timeout);

💬 Routing Examples

🔹 Local Command

await messageBus.CommandDispatcher.Local
    .Prepare(new CacheRefreshCommand())
    .WithTimeout(TimeSpan.FromSeconds(2))
    .SendAsync();

🔹 Machine-Scoped Broadcast

await foreach (var response in messageBus.CommandDispatcher.Machine
    .Prepare(new GetSystemStatusCommand())
    .WithTimeout(TimeSpan.FromSeconds(3))
    .StreamAsync())
{
    Console.WriteLine($"Local service reported: {response.State}");
}

🔹 Cluster-Wide Scatter-Gather

await foreach (var result in messageBus.CommandDispatcher.Cluster
    .Prepare(new SyncDatabaseCommand())
    .WithTimeout(TimeSpan.FromSeconds(5))
    .StreamResultAsync())
{
    if (result.IsSuccess)
        Console.WriteLine($"✔ Synced node: {result.Value.NodeName}");
    else
        Console.WriteLine($"⚠ Failed: {result.Error.Message}");
}

🔹 Directed Command (Targeted Application)

var response = await messageBus.CommandDispatcher.Network
    .Prepare(new GetMetricsCommand())
    .WithTimeout(TimeSpan.FromSeconds(2))
    .SendToAsyncWithResult("pc2");

Console.WriteLine($"Metrics from pc2: {response.CpuUsage}%");

🔹 Event Broadcast

await messageBus.EventDispatcher.Publish(
    new UserCreatedEvent(Guid.NewGuid(), "Alice"),
    TimeSpan.FromSeconds(5),
    CancellationToken.None
);

Handler:

public class UserCreatedEventHandler(ILogger<UserCreatedEventHandler> logger)
    : IEventHandler<UserCreatedEvent>
{
    public void Handle(UserCreatedEvent @event)
    {
        logger.LogInformation($"User created: {@event.UserName}");
    }
}

🧱 Fluent Command Builder Overview

Method Description
.WithTimeout(TimeSpan) Sets a per-command timeout
.WithCancellation(CancellationToken) Attaches external cancellation logic
.OnTimeout(Action<Exception, MeshContext>) Handles timeouts gracefully
.SendAsync() Sends a one-way command
.SendToAsync(string appId) Sends to a specific node
.SendToAsyncWithResult(string appId) Sends to a specific node and awaits reply
.StreamAsync() Streams multiple responses (scatter-gather)
.StreamResultAsync() Streams Result<T> objects (with success/error info)

Example:

await messageBus.CommandDispatcher.Cluster
    .Prepare(new ReplicateCacheCommand())
    .WithTimeout(TimeSpan.FromSeconds(4))
    .OnTimeout((ex, ctx) => Console.WriteLine($"Timeout on {ctx.ApplicationId}: {ex.Message}"))
    .SendAsync();

⚙️ Service Registration

services.AddEventHandlers();
services.AddCommandHandlers();

Automatically discovers and registers:

  • IEventHandler<T>
  • ICommandHandler<T>
  • ICommandHandler<T, TResult>

Works across .NET Framework, .NET Standard, .NET 8, and .NET 9.


🔍 SEO Keywords

.NET message bus • decentralized messaging • peer-to-peer message broker •
brokerless messaging system • distributed command routing • zero-broker architecture •
message queue alternative • high-performance messaging • event-driven .NET framework •
service mesh messaging • NetMQ command bus • publish/subscribe in .NET • scatter-gather commands


🤝 Contributing

Contributions are welcome! 🎉
Please open an issue first to discuss any proposed changes or enhancements.


📜 License

Licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.8 221 11/5/2025
0.0.7 207 11/4/2025
0.0.6 212 11/4/2025
0.0.4 186 10/10/2025
0.0.3 201 10/8/2025
0.0.2 225 9/29/2025
0.0.1 207 9/29/2025