MeshWeaver.Messaging.Hub 2.0.3

dotnet add package MeshWeaver.Messaging.Hub --version 2.0.3                
NuGet\Install-Package MeshWeaver.Messaging.Hub -Version 2.0.3                
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="MeshWeaver.Messaging.Hub" Version="2.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MeshWeaver.Messaging.Hub --version 2.0.3                
#r "nuget: MeshWeaver.Messaging.Hub, 2.0.3"                
#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.
// Install MeshWeaver.Messaging.Hub as a Cake Addin
#addin nuget:?package=MeshWeaver.Messaging.Hub&version=2.0.3

// Install MeshWeaver.Messaging.Hub as a Cake Tool
#tool nuget:?package=MeshWeaver.Messaging.Hub&version=2.0.3                

MeshWeaver.Messaging.Hub

Overview

MeshWeaver.Messaging.Hub implements the core modular components of the MeshWeaver ecosystem - Message Hubs. Based on the actor model pattern, each hub is an independent unit that processes messages sequentially and communicates with other hubs through message passing.

Key Concepts

Message Hubs

  • Each hub has a unique address for identification
  • Hubs process one message at a time (actor model)
  • Each hub has its own dependency injection container
  • Hubs can be instantiated dynamically
  • Support for hierarchical hosting of hubs

Features

  • Message routing between hubs
  • Request-response pattern support
  • Hierarchical hub hosting
  • Configurable message handlers
  • Built-in dependency injection
  • Asynchronous message processing

Usage Examples

Basic Request-Response Pattern

// Define message types
record SayHelloRequest : IRequest<HelloEvent>;
record HelloEvent;

// Configure message handler
configuration.WithHandler<SayHelloRequest>((hub, request) =>
{
    hub.Post(new HelloEvent(), options => options.ResponseFor(request));
    return request.Processed();
});

// Send request and await response
var response = await host.AwaitResponse(
    new SayHelloRequest(),
    o => o.WithTarget(new HostAddress())
);

Hierarchical Hub Hosting

// Create a sub-hub with its own address
var subHub = client.ServiceProvider.CreateMessageHub(
    new NewAddress(),
    conf => conf.WithTypes(typeof(Ping), typeof(Pong))
);

// Send message from sub-hub to host
var response = await subHub.AwaitResponse(
    new Ping(), 
    o => o.WithTarget(new HostAddress())
);

Configuration

Message hubs can be configured with custom handlers, message types, and processing options:

var configuration = new MessageHubConfiguration()
    .WithTypes(typeof(Ping), typeof(Pong))
    .WithHandler<Ping>((hub, request) => {
        // Handle message
    });

Integration

  • Seamless communication between MeshWeaver components
  • Support for distributed systems
  • Easy integration with dependency injection
  • Scalable message processing

See Also

Refer to the main MeshWeaver documentation for more information about the overall project architecture.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on MeshWeaver.Messaging.Hub:

Package Downloads
MeshWeaver.Activities

Package Description

MeshWeaver.Data

Package Description

MeshWeaver.Mesh.Contract

Package Description

MeshWeaver.Hosting

Package Description

MeshWeaver.Kernel

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.3 559 3/24/2025
2.0.2 534 3/24/2025
2.0.1 195 3/21/2025
2.0.0 225 3/20/2025
2.0.0-preview3 181 2/28/2025
2.0.0-Preview2 221 2/10/2025
2.0.0-preview1 215 1/6/2025
1.0.1 238 10/8/2024
1.0.0 228 10/8/2024