Franz.Common.Messaging.Hosting.MediatR
1.2.62
dotnet add package Franz.Common.Messaging.Hosting.MediatR --version 1.2.62
NuGet\Install-Package Franz.Common.Messaging.Hosting.MediatR -Version 1.2.62
<PackageReference Include="Franz.Common.Messaging.Hosting.MediatR" Version="1.2.62" />
paket add Franz.Common.Messaging.Hosting.MediatR --version 1.2.62
#r "nuget: Franz.Common.Messaging.Hosting.MediatR, 1.2.62"
// Install Franz.Common.Messaging.Hosting.MediatR as a Cake Addin #addin nuget:?package=Franz.Common.Messaging.Hosting.MediatR&version=1.2.62 // Install Franz.Common.Messaging.Hosting.MediatR as a Cake Tool #tool nuget:?package=Franz.Common.Messaging.Hosting.MediatR&version=1.2.62
Franz.Common.Messaging.Hosting.MediatR
An extension library within the Franz Framework that integrates MediatR with hosted messaging services. This package provides support for dispatching messages using MediatR pipelines within hosted services, enabling clean, decoupled, and testable messaging workflows.
Features
- MediatR Integration:
- Leverages MediatR for handling messaging strategies and execution.
- Hosted Messaging Service Support:
- Extends the Franz.Common.Messaging.Hosting package to include MediatR-based message processing.
- JSON Serialization:
- Supports Newtonsoft.Json for handling message payloads during MediatR operations.
Version Information
- Current Version: 1.2.62
- Part of the private Franz Framework ecosystem.
Dependencies
This package relies on:
- MediatR (12.2.0): Provides in-process messaging with pipelines.
- Newtonsoft.Json (13.0.3): Facilitates JSON serialization for message payloads.
- Franz.Common.Messaging.Hosting: Adds hosting support for messaging workflows.
Installation
From Private Azure Feed
Since this package is hosted privately, configure your NuGet client:
dotnet nuget add source "https://your-private-feed-url" \
--name "AzurePrivateFeed" \
--username "YourAzureUsername" \
--password "YourAzurePassword" \
--store-password-in-clear-text
Install the package:
dotnet add package Franz.Common.Messaging.Hosting.MediatR --version 1.2.62
Usage
1. Configure MediatR for Hosted Messaging
Use the MessagingStrategyExecuter
class to implement MediatR pipelines in hosted messaging workflows:
using Franz.Common.Messaging.Hosting.MediatR;
public class MyMessagingStrategyExecuter : IMessagingStrategyExecuter
{
private readonly IMediator _mediator;
public MyMessagingStrategyExecuter(IMediator mediator)
{
_mediator = mediator;
}
public async Task ExecuteAsync(MessageContext context)
{
// Dispatch the message using MediatR
await _mediator.Send(new MyMessageCommand { Payload = context.Message });
}
}
2. Register MediatR Services
Add MediatR and messaging services in the Startup
class:
using Franz.Common.Messaging.Hosting.MediatR;
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMediatR(typeof(MyMessageHandler).Assembly);
services.AddMessagingWithMediatR();
}
}
3. Implement MediatR Handlers
Define message handlers using MediatR's IRequestHandler
:
using MediatR;
public class MyMessageCommand : IRequest
{
public string Payload { get; set; }
}
public class MyMessageHandler : IRequestHandler<MyMessageCommand>
{
public Task<Unit> Handle(MyMessageCommand request, CancellationToken cancellationToken)
{
// Handle the message
Console.WriteLine($"Processing message: {request.Payload}");
return Unit.Task;
}
}
Integration with Franz Framework
The Franz.Common.Messaging.Hosting.MediatR package integrates seamlessly with:
- Franz.Common.Messaging.Hosting: Provides hosted services for messaging workflows.
- MediatR: Enables in-process messaging and pipelines.
- Newtonsoft.Json: Supports serialization of message payloads.
Contributing
This package is part of a private framework. Contributions are limited to the internal development team. If you have access, follow these steps:
- Clone the repository.
- Create a feature branch.
- Submit a pull request for review.
License
This library is licensed under the MIT License. See the LICENSE
file for more details.
Changelog
Version 1.2.62
- Added
MessagingStrategyExecuter
for integrating MediatR pipelines into messaging workflows. - Introduced support for JSON serialization using Newtonsoft.Json.
- Full compatibility with Franz.Common.Messaging.Hosting.
Product | Versions 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 was computed. 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. |
-
net8.0
- Franz.Common.Messaging.Hosting (>= 1.2.62)
- MediatR (>= 12.2.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Franz.Common.Messaging.Hosting.MediatR:
Package | Downloads |
---|---|
Franz.Common.Messaging.Bootstrap
Shared utility library for the Franz Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.62 | 50 | 1/8/2025 |