Hangfire + MediatR = Message Dispatcher

preview_player
Показать описание
You can use two popular libraries in MediatR and Hangfire to create a pretty cool solution to move messaging out-of-process into a separate worker. Here's how you can take these two libraries and use them together.

💥 Join this channel to get access to source code & demos!

🔥 Don't have the JOIN button? Support me on Patreon!

0:00 Intro
0:38 MediatR Example
1:25 Configure Hangfire
2:27 MediatR Wrapper/Bridge
3:20 MediatR Extension Method
4:37 Hangfire Serialization
8:00 Hangfire Extensibility
9:53 Summary

#dotnet #messaging #softwarearchitecture
Рекомендации по теме
Комментарии
Автор

If you're interested in more content around using MediatR and Hangfire together let me know. There's a few different things such as event handlers, retries, timeouts and how you can deal with them. Let me know in the comments what your interested in.

CodeOpinion
Автор

I'm binge watching your videos. Love the format, short and very informative. Thanks !

chadox
Автор

Why is this channel is so underrated. 😔

rainron
Автор

Why do u have only 4k subs ?! Your videos are so good.. Keep it up

majixx
Автор

Would love more videos on this. Would you extend MediatR publish method too?

feelingeverfine
Автор

After some more trying out, I really like this approach since we are able to use both the MediatR Send or the extension method you wrote where needed to switch between in and out process.

jessestruyvelt
Автор

Awesome, Great article.
I have a doubt, is there any way to run the worker project inside my API.
I don't want to run two applications.

velkumars
Автор

Is the use of MediatR relevant to hooking a CQRS implementation up to HangFire? Or is it a matter of extending whatever CQRS implementation you have to another method that moves that work out of process?"

noahginsburg
Автор

I did't understand how you managed to use mediator to talk with a separate process(the worker which hosts hangfire).As fire as i know medior works only in process.I think would me more suitable a message broker for interprocesses comunications

thedacian
Автор

Great video.

Question - would you not get the same effect if you invoke hangfire in the MediatR handler?

ConradAkunga
Автор

the hangfire can job with topic equals rabbit mq? in this example, when have a implementation witch listen a new Order event receive? i said this because, i need to execute anothers methods after create event new Order. can explain?

PedroHenrique-dilb
Автор

Thanks for video! Very helpful!

One question. Where should be located "Handle" method for processing data and do something? I suppose that it should be inside "Handfire.Mediatr" project, am I right? So "Handfire.Mediatr" project included in "Worker" and in "AspNetCore". "AspNetCore" use it to serialize information about data and method to be called and send ti Handfire storage. And "Worker" use "Handfire.Mediatr" to deserialized record from Handfire storage and execute needed method?

GambitVil
Автор

Hello,
Is it possible to share data between Hangfire jobs using this pattern ?
Or do you know a solution to make it possible with an other way ?

_PhOeNiX_
Автор

Hi, How do you get back to the CreateShippingLabel with this code? I never reach the Inotification point entry? thanks

kamarchand
Автор

Hii, Is it good approach to use Hangfire with the EntityFrameworkCore.Triggered library to easily replicate data from the write database to the read database whenever there are changes.
What are your thoughts on this approach? Do you think it's a good idea or are there any potential issues we should be aware of?

jeremyhb
Автор

I have been using dependency injection using Dapper, I have tried several ways to get to my Handler using MediatR but when I run Hangfire and get to the controller I find that I must correct the problem with dependency injection. I have also tried configuring my controller by creating an additional service to go through there, but I always run into the same problem. any recommendation or help

Fury_
Автор

At first, Postman showed "842ms". So, is that a lot of latency (say, by-product of process level indirection, or rather MVC?)?. It will be helpful if you could give some insights on improving on that front should be equally in part due to the use of MediatR, etc.

Of course, this will only increase from what it looks (though, benefits outweigh given the "pre implement" latency)?.

Overall, feels like a bit too much for achieving something which should be available in the language with relative simplicity?.

avineshwar
Автор

Hi, nice. But!

Why do we code all these bridge and extensions staff but not call the mediator Send as below? In the end we can switch out of process like this. What is the benefit or difference?

=> m.Send());

public interface IMyJob
{
[DisplayName("My Job")]
Task Send();
}

public class MyJob : IMyJob
{
private readonly ISender _mediator;

public MyJob(ISender mediator)
{
_mediator = mediator;
}

public async Task Send()
{
await _mediator.Send(new MyRequest());
}
}

zivasendrom
Автор

What do you think on this version vs Brighter. I know you are the author of Brighter so I'm curious on your thoughts.

feelingeverfine
Автор

how to combine recurring job and mediator pattern?

suhasbothe