JustSaying.FlexiblePublishers
7.1.2-pre.2
dotnet add package JustSaying.FlexiblePublishers --version 7.1.2-pre.2
NuGet\Install-Package JustSaying.FlexiblePublishers -Version 7.1.2-pre.2
<PackageReference Include="JustSaying.FlexiblePublishers" Version="7.1.2-pre.2" />
paket add JustSaying.FlexiblePublishers --version 7.1.2-pre.2
#r "nuget: JustSaying.FlexiblePublishers, 7.1.2-pre.2"
// Install JustSaying.FlexiblePublishers as a Cake Addin #addin nuget:?package=JustSaying.FlexiblePublishers&version=7.1.2-pre.2&prerelease // Install JustSaying.FlexiblePublishers as a Cake Tool #tool nuget:?package=JustSaying.FlexiblePublishers&version=7.1.2-pre.2&prerelease
JustSaying.FlexiblePublishers
A set of JustSaying IMessagePublisher replacements to perform different functions
QueuedMessagePublisher
A publisher that queues messages to be published at a later time. This is useful for when you want to publish messages in UoW functionality and you don't want to send the messages until the UoW is committed.
When publishing a message it can be optionally marked as isWhitelisted
. When processing the queue, all messages can be sent or only the ones marked as isWhitelisted
.
A middleware is provided which add this functionality onto IHandlerAsync<>
handlers automatically.
Usage
Either the IQueuedMessagePublisher
interface can be registered into DI which wraps the IMessagePublisher
instance, OR the IQueuedMessagePublisher
can be registered for both IMessagePublisher
resolutions and IQueuedMessagePublisher
resolutions, which is better as 3rd party code messages will be queued into the UoW as expected.
These examples use SimpleInjector but the theory is the same for all.
Setting up:
// Example for existing IMessagePublisher registration
// container.RegisterSingleton(() => builder.BuildPublisher());
// Approach to wrap the built IMessagePublisher into a QueuedMessagePublisher, then register this as both IMessagePublisher and IQueuedMessagePublisher
var messagingRegistration = Lifestyle.Scoped.CreateRegistration(
() => new QueuedMessagePublisher(loggerFactory, () => builder.BuildPublisher()),
container);
container.AddRegistration(typeof(IMessagePublisher), messagingRegistration);
container.AddRegistration(typeof(IQueuedMessagePublisher), messagingRegistration);
Configuring middleware:
x.ForTopic<TestMessage>(
cfg =>
{
cfg.WithMiddlewareConfiguration(m =>
{
m.UseQueuedMessagesMiddleware();
m.UseDefaults<TestMessage>(typeof(TestMessageHandler)); // Add default middleware pipeline
});
});
Using in app:
Publish a message normally:
private readonly IMessagePublisher _messagePublisher;
await _messagePublisher.PublishAsync(new TestMessage());
Publish a "isWhitelisted" message - this requires the IQueuedMessageInterface
private readonly IQueuedMessagePublisher _messagePublisher;
await _messagePublisher.PublishAsync(new TestMessage(), isWhitelisted: true);
Additional Notes
If using elsewhere (UoW approach on web controllers), then the queue must be processed at the end of the request handler. If using with a fully manual implementation then the queue must be processed once ready.
There is an example middleware for just with JustSaying 7 in here, and the same approach can be provided to middlewares for Mediator, ASP.NET Core pipelines etc.
Product | Versions 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- JustSaying (>= 7.1.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
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 |
---|---|---|
7.1.2-pre.2 | 42 | 12/17/2024 |
7.1.1-pre.2 | 28 | 12/16/2024 |
7.0.3 | 1,454 | 10/22/2024 |
7.0.2 | 4,359 | 2/9/2024 |
7.0.1 | 1,536 | 2/9/2024 |
7.0.0 | 425 | 2/5/2024 |
1.0.20 | 132 | 2/2/2024 |
1.0.19 | 99 | 2/2/2024 |
1.0.17 | 94 | 2/2/2024 |
1.0.15 | 119 | 2/1/2024 |
1.0.13 | 96 | 2/1/2024 |
1.0.12 | 122 | 1/30/2024 |
1.0.11 | 200 | 6/20/2023 |
1.0.10 | 7,485 | 6/23/2022 |
1.0.9 | 15,294 | 11/11/2019 |
1.0.7 | 1,181 | 10/3/2019 |