How To Build Loosely Coupled Microservices With MassTransit

Поделиться
HTML-код
  • Опубликовано: 19 окт 2024

Комментарии • 162

  • @MilanJovanovicTech
    @MilanJovanovicTech  Год назад +5

    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 Год назад +21

    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  Год назад +5

      This made my day! I'm very happy for you, mate. Keep crushing it! 🔥🔥

  • @kinggrizzly13
    @kinggrizzly13 Год назад +10

    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  Год назад +1

      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 Месяц назад

      Heyy could u share the POC i need this

  • @mistguides
    @mistguides Год назад +1

    Thank you, Milan. All the best vibes from Slovenia!

  • @ryoman76
    @ryoman76 Год назад +16

    Great! For next video Masstransit Saga ?

  • @zikkrype
    @zikkrype 7 месяцев назад +3

    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 месяцев назад +1

      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

  • @kodindoyannick5328
    @kodindoyannick5328 7 месяцев назад +1

    Thank you Milan. It's great content and very interesting.

  • @hattinnh
    @hattinnh 5 месяцев назад +1

    Thank you for taking the time to make this video, you are awesome!

  • @crazyfox55
    @crazyfox55 Год назад +5

    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.

  • @gretings
    @gretings 3 месяца назад +1

    Bro thanks a lot, thanks to you I was able to solve a problem I've been stumped on for a week!

  • @aweklin
    @aweklin Год назад +1

    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! ❤

  • @sauravbhatta5303
    @sauravbhatta5303 Год назад +4

    Great library

  • @gabrielzalisz
    @gabrielzalisz 6 месяцев назад +1

    I smashed the like button. It still looks awesome after being smashed. Greetings from Czechia!

  • @JayMatlou
    @JayMatlou 4 месяца назад

    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.

  • @adamf6621
    @adamf6621 Год назад +3

    nice video, will there be a video about event sourcing and saga patterns?

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад

      - Saga: ruclips.net/video/dlXCodLxhag/видео.html
      - Saga compensation: ruclips.net/video/FPVzevl6Ri8/видео.html
      I'll do a video on ES sooner or later

  • @iPazooki
    @iPazooki Год назад +1

    Thanks for your awesome video mate,
    It would be great if you create some videos about distributed tracing.

  • @iliqngorki3310
    @iliqngorki3310 Год назад +1

    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  Год назад +1

      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.

  • @KrzysztofBarbarski
    @KrzysztofBarbarski Год назад +2

    Good to se little bit longer videos focused more on software architecture

  • @f.donnet8165
    @f.donnet8165 Год назад +2

    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  Год назад +1

      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.

  • @lindermannla
    @lindermannla Год назад +1

    Excelent tutorial! Thxnz Milan!

  • @juliangzr4998
    @juliangzr4998 Год назад +1

    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?

  • @АнатолийБобко-щ6и
    @АнатолийБобко-щ6и Год назад +1

    Hi, Milan! Awesome and useful video! Do you always use primitives such as Result, Error and etc. in your projects?

  • @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 месяцев назад +2

      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

  • @ahmedlutfiobeidat2142
    @ahmedlutfiobeidat2142 3 месяца назад

    Thank you Milan you are amazing

  • @codemonk1999
    @codemonk1999 Год назад +1

    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!

  • @besikkristesiashvili
    @besikkristesiashvili Год назад +2

    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  Год назад +1

      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?

  • @lettuceturnipthebeets790
    @lettuceturnipthebeets790 Год назад +1

    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

  • @RohanShakya
    @RohanShakya Год назад +1

    Very informative video! How would we normally share 'Contracts' between two applications in a real world project?

  • @eziamakanv
    @eziamakanv Год назад +3

    Great tutorial Milan! As a suggestion could you please cover how an API gateway could be implemented for this project? Maybe using Ocelot?

  • @peddapetavenkatesh3854
    @peddapetavenkatesh3854 4 месяца назад

    best structure and High perfomance

  • @LucasHenriquedeBrito
    @LucasHenriquedeBrito Год назад +1

    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?

  • @AkashKarve-t2o
    @AkashKarve-t2o 7 месяцев назад +1

    If we go with clean architecture which layer will your prefer to keep masstransit library? Will it it application or infrastructure layer?

  • @antonmartyniuk
    @antonmartyniuk Год назад +1

    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

  • @kevinlloyd9507
    @kevinlloyd9507 Год назад +1

    @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 :)

  • @mohsinazamafridi8566
    @mohsinazamafridi8566 Год назад +1

    Great video,

  • @RMarjanovic
    @RMarjanovic Год назад +1

    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.

  • @rhexcasas8452
    @rhexcasas8452 Год назад +1

    very nice. thank you.

  • @HimabindhuBuska
    @HimabindhuBuska Год назад +1

    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?

  • @birgerg
    @birgerg Год назад +4

    Will not using a shared class library with the contracts create a hard dependency between your services?

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад +1

      You need a way to keep the services using the same contract. Later on, it can be distributed as a NuGet package.

    • @pilotboba
      @pilotboba Год назад +2

      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 3 месяца назад +1

      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”

  • @jstoturial9293
    @jstoturial9293 Год назад +3

    Please make video about saga and apigateway 😊

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад +1

      - Saga: ruclips.net/video/dlXCodLxhag/видео.html
      - Saga compensation: ruclips.net/video/FPVzevl6Ri8/видео.html
      - YARP load balancer (can easily be extended to API gateway): ruclips.net/video/0RaH9hhOF4g/видео.html

  • @gauravsingh-qt2zo
    @gauravsingh-qt2zo Год назад +1

    Milan can you make video on implementing oauth 1.0 and 2.0?

  • @habibulrehman9334
    @habibulrehman9334 7 месяцев назад

    Great content

  • @VytautasLL
    @VytautasLL Год назад +3

    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

  • @marshallkoo5294
    @marshallkoo5294 Год назад +1

    Is it possible to run the program after finishing work to see the results?

  • @microtech2448
    @microtech2448 Год назад +1

    That's straight to the point, that's good. What's your opinion on calling microservices through http clients?

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад +2

      Perfectly acceptable integration pattern. I'll do a separate video discussing HTTP vs Messaging

    • @microtech2448
      @microtech2448 Год назад

      Waiting for that 👍

  • @HamzaKhan-ld5fj
    @HamzaKhan-ld5fj Год назад +1

    Do i need to create complete docker-compose file or only the rabbitMq one?

  • @paikesitics
    @paikesitics 6 месяцев назад

    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  6 месяцев назад +1

      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 6 месяцев назад

      @@MilanJovanovicTech Noted. Thanks!

  • @mrcarlpaton
    @mrcarlpaton 6 месяцев назад +1

    How do we ensure CreateArticle will save to the dbcontext AND the created event is published? Ie: make the operation atomic?

  • @youssefelshabasy
    @youssefelshabasy Год назад +2

    If you are experienced with it, could you make a video on how we can use the actor model in DDD

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад +2

      I didn't work with the Actor model before, but I can make some introductory videos as I study the topic

  • @emanuelcordovamontiel1017
    @emanuelcordovamontiel1017 5 месяцев назад

    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  5 месяцев назад

      What do you mean by this? Select types of messages?

  • @2u1u
    @2u1u Год назад +1

    How would you keep microservices decoupled if microservice A needs data from microservice B without a direct call to eachother?

  • @balajisairamnarasimhan
    @balajisairamnarasimhan Год назад +1

    may I know why the publisher class always have to be static ?

  • @JuanCamba81
    @JuanCamba81 6 месяцев назад

    Awesome!

  • @kitanddaniel
    @kitanddaniel 8 месяцев назад

    Good information but you are not showing what is happening in RabbitMQ. For example: how many Queues were created? How to handle retries?

  • @Kylefuller002
    @Kylefuller002 4 месяца назад

    Would this work between .net framework and .net 8? Could I use masstransit to communicate back and forth?

    • @MilanJovanovicTech
      @MilanJovanovicTech  4 месяца назад

      In theory yes? It's just messages being sent over a message bus. But I can't say for sure.

  • @yuvrajgaikwad8972
    @yuvrajgaikwad8972 Год назад +1

    Can you do comparison mass transit vs Rebus

  • @yelshabasy
    @yelshabasy Год назад +1

    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?

  • @pilotboba
    @pilotboba Год назад +1

    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.

  • @NasirAli-yk9bp
    @NasirAli-yk9bp 4 месяца назад

    if you can please show how to implement synchronous communication with microservices 😋

  • @JimRohn-u8c
    @JimRohn-u8c Год назад +2

    Do they have a RUclips Channel like yours but for Java? 😭

  • @iyerpram
    @iyerpram Год назад +1

    Can we replace masstransit with nservicebus

  • @hamitkarahan2973
    @hamitkarahan2973 Год назад +1

    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.

  • @pramod.kulkarni9607
    @pramod.kulkarni9607 4 месяца назад

    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

  • @Maxim.Shiryaev
    @Maxim.Shiryaev Год назад +4

    And now come failures... DB not vavailable, messages lost etc. With all that transactional outboxes, sagas and so on.

  • @sunzhang-d9v
    @sunzhang-d9v Год назад +1

    The consumer reports an error, how to fix the system, how to re-execute

  • @NavodWickra
    @NavodWickra 25 дней назад

    MassTransit or ServiceStack?

  • @techpc5453
    @techpc5453 Год назад +2

  • @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.