Тёмный

How To Build Loosely Coupled Microservices With MassTransit 

Milan Jovanović
Подписаться 102 тыс.
Просмотров 35 тыс.
50% 1

Опубликовано:

 

26 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 162   
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Get the source code for this video for FREE → the-dotnet-weekly.ck.page/microservices Want to master Clean Architecture? Go here: bit.ly/3PupkOJ Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt
@rezvlt9285
@rezvlt9285 Год назад
I landed a high paying role because of your content! I'm hoping to land an even higher paying one next year. Great video, awesome stuff as always!
@MilanJovanovicTech
@MilanJovanovicTech Год назад
This made my day! I'm very happy for you, mate. Keep crushing it! 🔥🔥
@kinggrizzly13
@kinggrizzly13 Год назад
MassTransit is a fantastic library. I had to build a quick POC and use RabbitMQ with Docker. Then we decided to replace RabbitMQ with Azure Service Bus with ease! Great video!
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Did you run into any problems during that migration?
@kinggrizzly13
@kinggrizzly13 Год назад
@@MilanJovanovicTech No issues at all. Keep in mind this is a new project, so it has not been put in production at all.
@vaibhavvatsa2571
@vaibhavvatsa2571 7 дней назад
Heyy could u share the POC i need this
@zikkrype
@zikkrype 7 месяцев назад
Nice. It would be great if you focused more on exchanges, queues, topic, fanouts. I’m service bus guy, so i hoped to learn more about using rabbit with massyransit
@MilanJovanovicTech
@MilanJovanovicTech 7 месяцев назад
That might end up being a "boring" video for most 😅
@zikkrype
@zikkrype 7 месяцев назад
@@MilanJovanovicTech you definitely should mate, you have talent to explain everything in simple and practical manner without “water” and useless successful-success garbage
@hattinnh
@hattinnh 4 месяца назад
Thank you for taking the time to make this video, you are awesome!
@MilanJovanovicTech
@MilanJovanovicTech 4 месяца назад
Any time! :)
@mistguides
@mistguides Год назад
Thank you, Milan. All the best vibes from Slovenia!
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Appreciate it! Sve najbolje iz Srbije :)
@sauravbhatta5303
@sauravbhatta5303 Год назад
Great library
@MilanJovanovicTech
@MilanJovanovicTech Год назад
It's awesome 😁
@crazyfox55
@crazyfox55 Год назад
This is great. Do you think you could make a video about docker for this specific project? It would also be interesting to see how this could be deployed to AWS or Azure.
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Yeah, that could be a nice idea
@АнатолийБобко-щ6и
@@MilanJovanovicTech,it would be nice to see how to deploy rabbitMQ to Azure :)
@kodindoyannick5328
@kodindoyannick5328 6 месяцев назад
Thank you Milan. It's great content and very interesting.
@MilanJovanovicTech
@MilanJovanovicTech 6 месяцев назад
My pleasure!
@Aweklin
@Aweklin Год назад
Thanks Milan. As always, your videos are top-notch. However, I can't find the playlist for this series so it is easy to follow from the start. Stay awesome! ❤
@MilanJovanovicTech
@MilanJovanovicTech Год назад
This is the only video
@JayMatlou
@JayMatlou 3 месяца назад
I rarely like or subscribe to video but this tops the charts, Do you offer tutoring one on one. I need to improve my skills and also have a close mentor close by.
@MilanJovanovicTech
@MilanJovanovicTech 3 месяца назад
I don't do 1-1 mentoring :)
@KrzysztofBarbarski
@KrzysztofBarbarski Год назад
Good to se little bit longer videos focused more on software architecture
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Plenty more to come!
@ahmedlutfiobeidat2142
@ahmedlutfiobeidat2142 2 месяца назад
Thank you Milan you are amazing
@MilanJovanovicTech
@MilanJovanovicTech 2 месяца назад
Thanks!
@adamf6621
@adamf6621 Год назад
nice video, will there be a video about event sourcing and saga patterns?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
- Saga: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-dlXCodLxhag.html - Saga compensation: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-FPVzevl6Ri8.html I'll do a video on ES sooner or later
@peddapetavenkatesh3854
@peddapetavenkatesh3854 4 месяца назад
best structure and High perfomance
@MilanJovanovicTech
@MilanJovanovicTech 4 месяца назад
Thanks!
@iPazooki
@iPazooki Год назад
Thanks for your awesome video mate, It would be great if you create some videos about distributed tracing.
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Will do!
@besikkristesiashvili
@besikkristesiashvili Год назад
Hi Milan, I really enjoy your tutorials, can you explain the distribution of database in microservices? for example customers, orders and products. It 's little bit unclear for me.
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Basically you want every microservice to have its own database, holding the data required by that service
@besikkristesiashvili
@besikkristesiashvili Год назад
@MilanJovanovicTech when data is relational? Is it normal to have a full copy of tables into different databases according to microservices?
@codemonk1999
@codemonk1999 Год назад
Great video. thank you. Could you please create something with container. 1 container containing multiple services and they interacting with each other. In this scenario can the MQ be outside the container? Thanks again!
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Great suggestion!
@jstoturial9293
@jstoturial9293 Год назад
Please make video about saga and apigateway 😊
@MilanJovanovicTech
@MilanJovanovicTech Год назад
- Saga: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-dlXCodLxhag.html - Saga compensation: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-FPVzevl6Ri8.html - YARP load balancer (can easily be extended to API gateway): ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-0RaH9hhOF4g.html
@birgerg
@birgerg Год назад
Will not using a shared class library with the contracts create a hard dependency between your services?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
You need a way to keep the services using the same contract. Later on, it can be distributed as a NuGet package.
@pilotboba
@pilotboba Год назад
You could put the message classes in both projects, but they could get out of sync that way. You don't want the service to reference each other for sure.
@Oleks_
@Oleks_ Год назад
@@MilanJovanovicTech What do you think about these recommendations in this case? "The integration events can be defined at the application level of each microservice, so they are decoupled from other microservices, in a way comparable to how ViewModels are defined in the server and client. What is not recommended is sharing a common integration events library across multiple microservices; doing that would be coupling those microservices with a single event definition data library. You do not want to do that for the same reasons that you do not want to share a common domain model across multiple microservices: microservices must be completely autonomous. For more information, see this blog post on the amount of data to put in events. Be careful not to take this too far, as this other blog post describes the problem data deficient messages can produce. Your design of your events should aim to be "just right" for the needs of their consumers. There are only a few kinds of libraries you should share across microservices. One is libraries that are final application blocks, like the Event Bus client API, as in eShopOnContainers. Another is libraries that constitute tools that could also be shared as NuGet components, like JSON serializer." learn.microsoft.com/en-us/dotnet/architecture/microservices/multi-container-microservice-net-applications/integration-event-based-microservice-communications#integration-events
@markcabana5864
@markcabana5864 2 месяца назад
I think this is a limitation of masstransit, requiring same namespace for messages to be consumed. Requiring same namespaces on both ends is not “loosely coupled”
@mohsinazamafridi8566
@mohsinazamafridi8566 Год назад
Great video,
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Glad you enjoyed it
@2u1u
@2u1u Год назад
How would you keep microservices decoupled if microservice A needs data from microservice B without a direct call to eachother?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Sent that data using a queue
@rhexcasas8452
@rhexcasas8452 Год назад
very nice. thank you.
@MilanJovanovicTech
@MilanJovanovicTech Год назад
You're very welcome :)
@АнатолийБобко-щ6и
Hi, Milan! Awesome and useful video! Do you always use primitives such as Result, Error and etc. in your projects?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Most of the time, yes
@juliangzr4998
@juliangzr4998 Год назад
Hello Milan! Thank you for the video. I watch all your videos and they are all awesome! I wanted to ask you what happens if the consumer for any reason is not running at the moment the message is sent. In that case, the consumer is going to be able to receive the message the moment it starts running again?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Yes
@RohanShakya
@RohanShakya Год назад
Very informative video! How would we normally share 'Contracts' between two applications in a real world project?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
NuGet package
@gauravsingh-qt2zo
@gauravsingh-qt2zo Год назад
Milan can you make video on implementing oauth 1.0 and 2.0?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Maybe
@lettuceturnipthebeets790
@lettuceturnipthebeets790 Год назад
Milan, thank you for the awesome video! Could you share what VS extensions you use?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
I use ReSharper, Editor Guidelines, and Color Output for the build console highlighting
@marshallkoo5294
@marshallkoo5294 Год назад
Is it possible to run the program after finishing work to see the results?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Yes
@habibulrehman9334
@habibulrehman9334 6 месяцев назад
Great content
@MilanJovanovicTech
@MilanJovanovicTech 6 месяцев назад
Thanks!
@RMarjanovic
@RMarjanovic Год назад
This is the first time I've seen joining queries from different tables by doing a call in a call, thanks for showing this. Are there any negative effects to that the outer call being asynchronous and the inner call being synchronous? Also is this breaking principles if I would do this in domain driven design but with two aggregates?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
The inner call isn't really a "call" - it just produces an IQueryable which EF can include in the expression tree. So it's just a single query at the end of the day.
@mrcarlpaton
@mrcarlpaton 5 месяцев назад
How do we ensure CreateArticle will save to the dbcontext AND the created event is published? Ie: make the operation atomic?
@MilanJovanovicTech
@MilanJovanovicTech 5 месяцев назад
Outbox/Inbox
@AkashKarve-t2o
@AkashKarve-t2o 6 месяцев назад
If we go with clean architecture which layer will your prefer to keep masstransit library? Will it it application or infrastructure layer?
@MilanJovanovicTech
@MilanJovanovicTech 6 месяцев назад
Infrastructure
@AkashKarve-t2o
@AkashKarve-t2o 6 месяцев назад
@@MilanJovanovicTech could you make video for it
@kevinlloyd9507
@kevinlloyd9507 Год назад
@Milan what are your views on MassTransit vs Rebus? I just referenced your Saga Pattern video using Rebus for work. Now I woke up with more questions :)
@MilanJovanovicTech
@MilanJovanovicTech Год назад
I think MassTransit is more powerful
@VytautasLL
@VytautasLL Год назад
How do you handle data loss? For example after you publish some event (service A) and it is important, that other system/service (B) received this event. Let's say I stopped B service for update. What about such scenario?
@ArinSinabian
@ArinSinabian Год назад
It will queue up in RabbitMQ until service B is up again. If RabbitMQ is down you could use outbox pattern. I think milan has video for that as well.
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Service B stops while handling the event?
@ArinSinabian
@ArinSinabian Год назад
@@MilanJovanovicTech i am not sure about masstransit but if you throw exceptions while handling the event in service B masstransit wont send ack to rabbitmq. Isn't that so?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
@@ArinSinabian Yes, but I'm trying to clarify if that's what he meant
@2u1u
@2u1u Год назад
I would assume the message sits on the queue until its handled
@balajisairamnarasimhan
@balajisairamnarasimhan 11 месяцев назад
may I know why the publisher class always have to be static ?
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
But it isn't? 🤔
@emanuelcordovamontiel1017
@emanuelcordovamontiel1017 4 месяца назад
This is amazing!!! But if I want to consume only selected messages, I mean, How my application can consume only selected messages and leave others message in the queue
@MilanJovanovicTech
@MilanJovanovicTech 4 месяца назад
What do you mean by this? Select types of messages?
@antonmartyniuk
@antonmartyniuk Год назад
Great video! Any plans on GraphQL HotChocolate content ? This could also be with microservices like Schema Stitching, Federation and the most recent one - HotChocolate Fusion
@MilanJovanovicTech
@MilanJovanovicTech Год назад
No GraphQL planned at this point in time
@JuanCamba81
@JuanCamba81 5 месяцев назад
Awesome!
@MilanJovanovicTech
@MilanJovanovicTech 5 месяцев назад
Thanks!
@LucasHenriquedeBrito
@LucasHenriquedeBrito Год назад
Amazing vídeo! If I need to getId from another context/domain, I would using the autorest integrated with my CI/CD and generate a sdk instead. It seems less work 😅. However, what are your thoughts about it?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Seems like a nice idea
@ryoman76
@ryoman76 Год назад
Great! For next video Masstransit Saga ?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Great idea!
@paikesitics
@paikesitics 5 месяцев назад
Hi Milan, thanks for explanation. How about structuring consumer class in respect to Clean Architecture? According to my understanding from this video, it was in Application Layer (CMIIW), but for communication to the external layer, CA required us to place the code in Infrastructure layer.
@MilanJovanovicTech
@MilanJovanovicTech 5 месяцев назад
I'll have to do a take two on this video. These days, I place the consumers in Presentation (like another endpoint). And only use them to send commands.
@paikesitics
@paikesitics 5 месяцев назад
@@MilanJovanovicTech Noted. Thanks!
@JimRohn-u8c
@JimRohn-u8c Год назад
Do they have a RU-vid Channel like yours but for Java? 😭
@MilanJovanovicTech
@MilanJovanovicTech Год назад
I'm not aware of it 😅
@youssefelshabasy
@youssefelshabasy Год назад
If you are experienced with it, could you make a video on how we can use the actor model in DDD
@MilanJovanovicTech
@MilanJovanovicTech Год назад
I didn't work with the Actor model before, but I can make some introductory videos as I study the topic
@kitanddaniel
@kitanddaniel 7 месяцев назад
Good information but you are not showing what is happening in RabbitMQ. For example: how many Queues were created? How to handle retries?
@MilanJovanovicTech
@MilanJovanovicTech 7 месяцев назад
Noted
@Maxim.Shiryaev
@Maxim.Shiryaev Год назад
And now come failures... DB not vavailable, messages lost etc. With all that transactional outboxes, sagas and so on.
@MilanJovanovicTech
@MilanJovanovicTech Год назад
The fun of microservices :)
@HimabindhuBuska
@HimabindhuBuska Год назад
Hi Milan, Where you added queue and exchanges configurations.
@MilanJovanovicTech
@MilanJovanovicTech Год назад
MassTransit takes care of that behind the scenes
@HimabindhuBuska
@HimabindhuBuska Год назад
@@MilanJovanovicTech can we handle multiple consumers using this mass transit?
@microtech2448
@microtech2448 Год назад
That's straight to the point, that's good. What's your opinion on calling microservices through http clients?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Perfectly acceptable integration pattern. I'll do a separate video discussing HTTP vs Messaging
@microtech2448
@microtech2448 Год назад
Waiting for that 👍
@HamzaKhan-ld5fj
@HamzaKhan-ld5fj 11 месяцев назад
Do i need to create complete docker-compose file or only the rabbitMq one?
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
You can run RabbitMQ independently, of course
@yelshabasy
@yelshabasy Год назад
Is this the same as domain events, a little confused on that
@MilanJovanovicTech
@MilanJovanovicTech Год назад
No, these would be integration events. Domain events are bound to a single domain. Integration events leave the boundary of a domain.
@tapqus
@tapqus Год назад
Why at 18:30 you fetching Events collection from another query instead of join & select from navigation property?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Because I'm not using a navigation property 🤷‍♂️
@pilotboba
@pilotboba Год назад
Why don't you map the Article and ArticleEvents relationship in the Consumer/Reporting Project? It would simplify your query.
@MilanJovanovicTech
@MilanJovanovicTech Год назад
I could've just exposed a navigation property sure. But in my mind, the ArticleEvents collection is unbounded so I opted not to do it.
@pilotboba
@pilotboba Год назад
@@MilanJovanovicTech Fair enough. But, in this cause I would have used the Join method in the query rather than the context method you used. Although in resolution it might end up wit the same query. But, I'd prefer the join for code clarity.
@pramod.kulkarni9607
@pramod.kulkarni9607 3 месяца назад
I am facing problem in my project i will explain simple i have 2databases 1is master where i have ticketstatus tabel and i have ticket database where i am storing ticketstatusid in get tickets api u want to send ticketstatus data as well with tickets By now u might have understood these are 2different apis whats solution for this
@MilanJovanovicTech
@MilanJovanovicTech 3 месяца назад
Query both of them?
@yuvrajgaikwad8972
@yuvrajgaikwad8972 Год назад
Can you do comparison mass transit vs Rebus
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Maybe 🤔
@NasirAli-yk9bp
@NasirAli-yk9bp 3 месяца назад
if you can please show how to implement synchronous communication with microservices 😋
@MilanJovanovicTech
@MilanJovanovicTech 3 месяца назад
HTTP?
@NasirAli-yk9bp
@NasirAli-yk9bp 3 месяца назад
Or grpc
@Kylefuller002
@Kylefuller002 3 месяца назад
Would this work between .net framework and .net 8? Could I use masstransit to communicate back and forth?
@MilanJovanovicTech
@MilanJovanovicTech 3 месяца назад
In theory yes? It's just messages being sent over a message bus. But I can't say for sure.
@iyerpram
@iyerpram Год назад
Can we replace masstransit with nservicebus
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Yes
@sunzhang-d9v
@sunzhang-d9v Год назад
The consumer reports an error, how to fix the system, how to re-execute
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Retries, dead-lettering are some of the things you can do
@sunzhang-d9v
@sunzhang-d9v Год назад
@@MilanJovanovicTech
@hamitkarahan2973
@hamitkarahan2973 Год назад
Hey Milan, I'd like to know can we use AWS SQS instead of RabbitMQ as MassTransit. Or what is its equivalent on AWS? I am confused about how can we use pub-sub method with RabbitMQ. I think I have a concept and definition confusion.
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Yes, check here: masstransit.io/documentation/transports
@NavodWickra
@NavodWickra 2 дня назад
MassTransit or ServiceStack?
@MilanJovanovicTech
@MilanJovanovicTech День назад
MassTransit
@codenetw
@codenetw 3 месяца назад
I don't like MassTransit because it creates a wrapper around the message. If it were possible to pass the service data not in the wrapper but in the message header, it would be ideal.
@MilanJovanovicTech
@MilanJovanovicTech 3 месяца назад
Better build it all yourself 🤷‍♂️
@_JustBeingCasual
@_JustBeingCasual 7 месяцев назад
Hallo @MilanJovanovicTech, there is something I'm not sure about Microservices are made so they are scalable so the 'Newsletter.Reporting.Api' might have 10 instances because it's heavily used; wouldn't this mean the consumer is called on 10 different api's which means 10 entries are added? What is the round away method to avoid this?
@MilanJovanovicTech
@MilanJovanovicTech 7 месяцев назад
if you run multiple instances of the same service it will load balance the receive endpoints by default.
@f.donnet8165
@f.donnet8165 11 месяцев назад
Great article. Do you think it's better to publish the event before the SaveChangesAsync in the DB and have a consumer in both apis to consume the message and use it to save the data ? Because with your aproach, if you loose the connection with your message broker, you loose your message and have a data problem (one db updated but not the other)? Or it's overkill ?
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Always publish after it becomes a fact. So publish after SaveChanges is the only thing that makes sense. As far as reliability issues, there's the Outbox pattern for that.
@gabrielzalisz
@gabrielzalisz 5 месяцев назад
I smashed the like button. It still looks awesome after being smashed. Greetings from Czechia!
@MilanJovanovicTech
@MilanJovanovicTech 5 месяцев назад
Legend!
@gretings
@gretings 2 месяца назад
Bro thanks a lot, thanks to you I was able to solve a problem I've been stumped on for a week!
@MilanJovanovicTech
@MilanJovanovicTech 2 месяца назад
Glad I could help 😁
@iliqngorki3310
@iliqngorki3310 Год назад
In many case's you can FireAndForget and not to wait for executing the second microservice. Kafka has this option maybe RabbitMQ can also. This is my opinion. Nice video, cheers.
@MilanJovanovicTech
@MilanJovanovicTech Год назад
This is doing that - when the publish to the queue completes, the initial request is done. It's also just instantly hitting the consumer breakpoint, so it might give that impression.
@lindermannla
@lindermannla Год назад
Excelent tutorial! Thxnz Milan!
@MilanJovanovicTech
@MilanJovanovicTech Год назад
You're welcome :)
@aditsheth1896
@aditsheth1896 11 месяцев назад
Milan Thanks for the easy explanation. I am regulary following your videos and articles to implement the application architecture from scratch. I have few questions 1. How to handle multiple consumer for single event? eg. OrderCreated event to handle the reduce inventory, Update the counts for user order, product sellCount, etc... 2. Does the request wait untill all multiple event consumed..? 3. Is it mandatory to wait for response? eg. OrderCreated Email or SMS send..?
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
1. MassTransit takes care of it. You just write the consumers. And each handler will run concurrently. This is important to keep in mind. 2. No. It will just publish. Maybe there's a way to wait for ACK message (worth checking) 3. No
@nnaemekaeziamaka7116
@nnaemekaeziamaka7116 Год назад
Great tutorial Milan! As a suggestion could you please cover how an API gateway could be implemented for this project? Maybe using Ocelot?
@MilanJovanovicTech
@MilanJovanovicTech Год назад
Great suggestion!
@techpc5453
@techpc5453 Год назад
@MilanJovanovicTech
@MilanJovanovicTech Год назад
👋
Далее
Fix Your Controllers By Refactoring To Minimal APIs
14:56
Request Response Messaging Pattern with MassTransit
17:48
А вы играли в school boy runaway?
00:30
Просмотров 122 тыс.
Stop Using FirstOrDefault in .NET! | Code Cop #021
12:54
NestJs Microservices with RabbitMQ
23:21
Просмотров 13 тыс.
LINQ's INSANE Improvements in .NET 9
11:26
Просмотров 44 тыс.
А вы играли в school boy runaway?
00:30
Просмотров 122 тыс.