Saga Pattern For Microservice Architecture With Rebus And RabbitMQ

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

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

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

    Want to master Clean Architecture? Go here: bit.ly/3PupkOJ
    Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt

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

    simplest explanation of the saga pattern I ever heard and saw with very practical example, thank you

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

    Good video ! I can't wait to see how you will implement the compensating transactions ! Thanks Milan for your job !

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

    A nice and short tutorial. But how are you going to implement rollback flow in case of failure on one of the steps? It would be great to demonstrate this as well.

  • @jameshancock
    @jameshancock Год назад +17

    This is great! Are you planning on doing an error handling video on this?

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

      That's the plan!

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

      I was curious about this also, I'm assuming the persisted saga can resume from a given point if a step fails and is then resolved?

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

      @@mylesdavies9476 yes in the case where it was transient. The issue for me is how do you unwind a saga if a required step fails?

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

      @@jameshancock MassTransit has a Routing Slip pattern with compensation for activities to allow a rollback if needed.

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

    Great content, but you have shown happy case scenario. How to complete the implementation (with Rebus for example) if last part of saga failed? How to do "rollback" and configure it? How it works?

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

      I'll tackle that in a future video, this one was already pretty long

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

    Hi Milan, when you first save your order into the database and then publish your order created event. I have seen a library such as CAP nuget package provide you with an atomic transaction between the database and the bus to ensure that you get both operations succeeded rather than in some cases when the message bus is offline only getting the database activity occur.
    It is also known as the outbox pattern.

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

      I'm aware 😁 I've talked about the Outbox pattern before, but didn't want to add too much complexity in a single video.

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

    You do wonderful work in practical way. Thank you.

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

    Could you briefly describe what are the benefits of this approach compaired to direct calling of smth like IEmailSender in the mediator? As I get, it allows us to store staging state and somehow guarantee that if smth is wrong on the SMPT server side (for example), we're going to deliver the user an email anyway. Am I right?

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

    Great video Milan!, agree with other some error/rollback logic would be very nice to see.
    Keep up the good work!

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

    Hi Milan, nice explanation. Just a question, based on clean architecture we should try to avoid dependencies in external libraries in the application layers - so how we can solve that?

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

    Hi Milan, excelent explanation. Just a question, according to the examples it's possible return a value (id) after SAGA process finished? For example, to newsletters endpoint?

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

      The Saga is asynchronous, so your endpoint can't wait for it to complete

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

    I may have missed a video, but do you prefer or recommend Rebus over Masstransit?

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

      I don't prefer either one. I worked with both. From me experience, Rebus is a lot simpler to configure.

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

    Hello. Thanks for sharing it @Milan. Could you please tell me what theme you're using for VS?

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

    Hi Milan, any chance you can make a slower more background video is more beginner friendly on this important topic ? I guess giving background why use Rebus, what are the main abstractions in a Saga etc.

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

    Looks great, does it make sence to use this with CAP? Or the Rebus implementation already contains a CAP like functionality?

  • @khalednabil2278
    @khalednabil2278 8 дней назад

    hi milan,
    thanks for your errorts, i need to implement the app you start with to implement saga pattern
    is there any video where you start building this app which's you begin with or you implement it alone?

    • @MilanJovanovicTech
      @MilanJovanovicTech  8 дней назад

      eShop is a pretty old project, not sure where I started it. Might be ~2 year old video

  • @allen9504
    @allen9504 10 месяцев назад +1

    Masstransit also supports Sagas?
    What are pros and cons vs rebus?

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

    Are you using CQRS pattern? I’m new to this pattern and rebus and i am curious how can we implement CQRS with rebus

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

      CQRS is just about splitting your reads and writes logically in your code

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

    Hi Milan !What have you got on the ApplicationAssemblyReference class ?

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

    Could not resolve Rebus.RabbitMq.RabbitMqTransport with decorator depth 0 - registrations: Rebus.Injection.Injectionist+Handler

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

    Can you do a video using the Saga pattern with MassTransit with mediator please.

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

    This is a great topic , can we merge this with retry policy and dead queue in case one of consumers are down

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

    Very good content! will be nice if you make a video about massTransit

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

      There already is one, although it's basic and doesn't cover Sagas

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

    Nice video, Milan!
    I wish the video was focused on Orchestrated SAGA in a comprehensive way, like executing different transactions in different services (maybe 3 different services), compensating steps if something failed in between, and maybe more realistic example; maybe creating order, then deduct qty in "Stock service", then bill it in an invoice (invoice service)

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

      I've a video coming out about a failure case and compensations

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

      @@MilanJovanovicTech I will be waiting for it 👍
      Long Question please bear with me: If user clicks on "Submit order" from UI and an http request sent to a Web API that starts a saga, it seems we will return a success to the user while the SAGA is still going in the backend; sending integration events for emails and other things, and other services still handling those events, maybe end up compensating for the whole Saga, what if the user doesn't want to see a success message unless we're 100% sure the saga completed successfully or error message if SAGA failed & fully compensated?

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

      @@alaaalnajjar1824 You show a simple message like "We're processing your order" and just orchestrate the saga accordingly

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

      @@MilanJovanovicTech This will work but for some functions I don't think it will accept "we're processing, you will know once it's done", maybe the user has to stay on UI screen and never leave it unless a definitive result is received from SAGA about the order he's adding, in such case...I think we will need some kind of notification pushed from the server? maybe last step in SAGA (either completing/compensating) pushes SAGA result to a notification/SignalR, consumed by frontend and act upon it by showing success message and close the screen, or stay on screen and show the error/returned message, Am I right ? Is there a better way ?

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

    Great video, very informative. Will be testing it out soon

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

    What is assigned to "ApplicationAssemblyReference" ?

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

    Good video Milan!

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

    It would be nice to see another important part of the Saga pattern: error handling by configuring retries and issuing a compensation transaction in a case of a fail

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

      As luck would have it, I just released such a video 😁😁

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

    Now let's see the same pattern using a MassTransit Saga.

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

    Great video, thank you!

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

    Great video! Why do you use Rebus to implement saga pattern and not use Masstransit?

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

      I wanted to try out Rebus and show it to you guys :)

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

      @@MilanJovanovicTech Will you make a video for implementing saga with masstransit?

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

    which operating system are you using ?

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

      Windows

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

      @@MilanJovanovicTech i asked you this question because one of your video i see you select docker and other things linux wise.

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

    Brate, can you say me what is your “vs template”? Font-colors are very good.
    Thank you for this video. 😊

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

      VS dark theme + ReSharper color highlighting

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

      @@MilanJovanovicTech thank you so much brate. Pozzzic from Istanbul. 🍻😊

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

    What will happen if the app goes down and the saga was not completed?

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

      Since it's persisted, it can continue from it left off, assuming the messages are retried

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

    can you recommend a good source of functional programming Milan ?

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

      Zoran Horvat for RUclips, also any talk from Simon Painter, Scott Wlaschin

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

      @@MilanJovanovicTech thanks alot my friend ❤️

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

    Wow what we have here ..... interesting ))))))))

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

      Did it meet expectiations?

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

      @@MilanJovanovicTech yes man very nice, would be great to see some compensation action if something is failed but i saw same question on other comment so will wait for that. Also what disadvantages you feel sagas have, except of implementation complexity ?

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

    This is Great

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

    Should a request handler be aware of being a part of a saga in the first place?

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

    This is too much "orchestration of business logic" inside the code".
    I would use CAMUNDA to do all this stuff, and implement "classic handler" only.
    It is than up the modelled workflow in camunda to decide what to do, what to call, how to handle errors etc.

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

    your work is valuable, and I think you have the right to ask for remuneration, but if you already monetize your videos, you still want more? what about the students who don't have the money to contribute on patreon and can't see the whole picture? In the end it turns out to be a video that they end up selling to you.

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

      This video made a whopping $59 in 486 days, quite a lot no doubt. 😅
      Try here: github.com/m-jovanovic/newsletter-orchestrated-saga

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

      @@MilanJovanovicTech Thank you very much Milan and I am sorry for being so rude. I appreciate what you do

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

    Your Patreon is expensive, $9 per month just for the source code! Love your content but damn, that's a lot. I am surprised you have 597 patrons, this youtube channel is not that big. I assume the supporters are mainly from your newsletter. Love your vids but just to get the source code that price is a steep monthly cost. I would like to support you though, I might pay for just a month and get the source code then unsubscribe.

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

      Is that with taxes? Cause it should be $5,99. The channel may not be "big", yet. But I interact with many people, try to be helpful. By the way, how much is a cup of coffee where you're at?

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

    So this is why Elsa exists lol this is crazy verbose.

  • @qingweige7127
    @qingweige7127 10 месяцев назад

    Great video!! Thank you for your video, it has benefited me a lot. But I have a question, how do I guarantee that the _bus.Send method will send 100% of the messages to the RabbitMq Server after Context.SaveChanges is executed? that code is at #15:57 of this video.