MeshWeaver.Messaging.Contract
2.5.0
See the version list below for details.
dotnet add package MeshWeaver.Messaging.Contract --version 2.5.0
NuGet\Install-Package MeshWeaver.Messaging.Contract -Version 2.5.0
<PackageReference Include="MeshWeaver.Messaging.Contract" Version="2.5.0" />
<PackageVersion Include="MeshWeaver.Messaging.Contract" Version="2.5.0" />
<PackageReference Include="MeshWeaver.Messaging.Contract" />
paket add MeshWeaver.Messaging.Contract --version 2.5.0
#r "nuget: MeshWeaver.Messaging.Contract, 2.5.0"
#:package MeshWeaver.Messaging.Contract@2.5.0
#addin nuget:?package=MeshWeaver.Messaging.Contract&version=2.5.0
#tool nuget:?package=MeshWeaver.Messaging.Contract&version=2.5.0
MeshWeaver.Messaging.Contract
Overview
MeshWeaver.Messaging.Contract defines the core interfaces, types, and abstractions that power the MeshWeaver messaging system. This library provides the contract definitions that enable type-safe message passing between hubs and standardized message handling patterns.
Core Concepts
Addresses
// Unique identifiers for message hubs
public record Address(string Type, string Id);
public record HostAddress() : Address("host", "main");
Message Contracts
Request-Response Pattern
// Base interface for request messages
public interface IRequest<TResponse>
{
// Marker interface for requests expecting TResponse
}
// Message delivery interface
public interface IMessageDelivery<TMessage>
{
TMessage Message { get; }
}
Message Hub Interface
public interface IMessageHub
{
// Send a message and await response
Task<IMessageDelivery<TResponse>> AwaitResponse<TResponse>(
IRequest<TResponse> request,
Action<MessageOptions> configureOptions,
CancellationToken cancellationToken = default
);
// Post a message without waiting for response
void Post<TMessage>(
TMessage message,
Action<MessageOptions> configureOptions
);
}
Message Options
public class MessageOptions
{
// Configure message as response to a request
public void ResponseFor<T>(T request);
// Set target hub address
public void WithTarget(Address address);
}
Configuration
Hub Configuration
public class MessageHubConfiguration
{
// Register message types
public MessageHubConfiguration WithTypes(params Type[] types);
// Register message handler
public MessageHubConfiguration WithHandler<TRequest>(
Func<IMessageHub, TRequest, Task> handler
);
}
Usage Patterns
Defining Messages
// Request message
record PingRequest : IRequest<PongResponse>;
// Response message
record PongResponse;
Message Handler Registration
configuration.WithHandler<PingRequest>((hub, request) =>
{
// Handle the request
hub.Post(new PongResponse(), opt => opt.ResponseFor(request));
return request.Processed();
});
Best Practices
- Always define request-response pairs using the
IRequest<TResponse>interface - Use strongly-typed messages for type safety
- Keep message contracts simple and serializable
- Use meaningful addresses for hub identification
- Configure message timeouts for reliability
- Handle message failures gracefully
Integration
- Used by MeshWeaver.Messaging.Hub for message processing
- Provides contract definitions for all MeshWeaver messaging components
- Enables custom message hub implementations
See Also
Refer to the main MeshWeaver documentation for more information about the overall messaging architecture.
| Product | Versions 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. 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. |
-
net9.0
- MeshWeaver.ShortGuid (>= 2.5.0)
- Microsoft.Extensions.Logging (>= 9.0.9)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on MeshWeaver.Messaging.Contract:
| Package | Downloads |
|---|---|
|
MeshWeaver.Messaging.Hub
Package Description |
|
|
MeshWeaver.Data.Contract
Package Description |
|
|
MeshWeaver.Mesh.Contract
Package Description |
|
|
MeshWeaver.Markdown.Collaboration
Package Description |
|
|
MeshWeaver.Markdown.Export.Contract
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-rc7 | 0 | 8/22/2026 |
| 3.0.0-rc6 | 110 | 8/20/2026 |
| 3.0.0-rc5 | 248 | 8/19/2026 |
| 3.0.0-rc3 | 488 | 8/16/2026 |
| 3.0.0-rc2 | 521 | 8/14/2026 |
| 3.0.0-rc1 | 415 | 8/13/2026 |
| 3.0.0-preview1 | 361 | 4/16/2026 |
| 2.5.0 | 614 | 11/3/2025 |
| 2.4.0 | 588 | 10/2/2025 |
| 2.3.0 | 573 | 8/4/2025 |
| 2.2.0 | 859 | 7/21/2025 |
| 2.1.0 | 502 | 4/6/2025 |
| 2.0.3 | 826 | 3/24/2025 |
| 2.0.2 | 811 | 3/24/2025 |
| 2.0.1 | 459 | 3/21/2025 |
| 2.0.0 | 499 | 3/20/2025 |
| 2.0.0-preview3 | 435 | 2/28/2025 |
| 2.0.0-Preview2 | 484 | 2/10/2025 |
| 2.0.0-preview1 | 475 | 1/6/2025 |
| 1.0.1 | 489 | 10/8/2024 |