how to use the publish-strategies of MediatR 12.0
See original GitHub issueI don’t understand how to use the publish-strategies of MediatR, can anyone give me an example?
public static async Task DispatchDomainEvents(this IMediator mediator, DbContext context,List<DomainEvent> deletedDomainEvents)
{
// If the delete domain events list has a value publish it first.
if (deletedDomainEvents.Any())
{
foreach (var domainEvent in deletedDomainEvents)
await mediator.Publish(domainEvent);
}
var entities = context.ChangeTracker
.Entries<BaseEntity>()
.Where(e => e.Entity.DomainEvents.Any())
.Select(e => e.Entity);
var domainEvents = entities
.SelectMany(e => e.DomainEvents)
.ToList();
entities.ToList().ForEach(e => e.ClearDomainEvents());
foreach (var domainEvent in domainEvents)
await mediator.Publish(domainEvent);
}
I want to use the PublishStrategy.ParallelNoWait strategy to send notifications.
Issue Analytics
- State:
- Created 7 months ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Publishing strategies in MediatR | Fati Iseni - Blog
Explore advanced publishing strategies with the MediatR library in .NET applications. This article dives into the Mediator pattern, ...
Read more >How to change MediatR publish strategy
how is it possible to configure another publishing strategy when using MediatR? basically i need to configure it to use publishingStrategy.
Read more >MNW #030: How To Publish MediatR Notifications In Parallel
Configuring MediatR Notification Publishing Strategy If you want to use the TaskWhenAllPublisher strategy, you can either: Provide a value for ...
Read more >MediatR 12.0 Released
This is a pretty big release, with a number of breaking changes. ... Breaking changes include: ... The migration guide includes instructions for ......
Read more >MediatR Publish and Send Methods
The Publish method enables one-to-many communication by broadcasting messages without expecting a response. It promotes loose coupling, and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, I resolve it !
then publish like below:
Finally, CustomPublisher.cs
Thank you for your reply. if I want to use PublishStrategy.ParallelNoWait: Can I write this right?