Saga Pattern For Microservice Architecture With Rebus And RabbitMQ

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ม.ค. 2025

ความคิดเห็น • 112

  • @MilanJovanovicTech
    @MilanJovanovicTech  ปีที่แล้ว +1

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

    • @qasimislamch
      @qasimislamch ปีที่แล้ว

      Thanks for the reply ❤️

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

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

  • @radeksendecki9922
    @radeksendecki9922 ปีที่แล้ว +1

    You do wonderful work in practical way. Thank you.

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว

      Thank you very much, Radek! Happy to contribute :)

  • @erikwiktorsson6841
    @erikwiktorsson6841 ปีที่แล้ว +2

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

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

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

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

  • @nove1398
    @nove1398 ปีที่แล้ว +1

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

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

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

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว

      Decoupling + it scales better in a microservice environment

  • @cyasotha
    @cyasotha 8 หลายเดือนก่อน

    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?

  • @qingweige7127
    @qingweige7127 ปีที่แล้ว

    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.

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

  • @allen9504
    @allen9504 11 หลายเดือนก่อน +1

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

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

  • @mike19821028
    @mike19821028 ปีที่แล้ว +1

    Great video, thank you!

  • @JuanCamba81
    @JuanCamba81 9 หลายเดือนก่อน

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

  • @khalednabil2278
    @khalednabil2278 หลายเดือนก่อน

    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  หลายเดือนก่อน

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

  • @milicabozic3827
    @milicabozic3827 ปีที่แล้ว +1

    Good video Milan!

  • @sunnypatel1045
    @sunnypatel1045 ปีที่แล้ว +2

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

  • @Ajmal_Yazdani
    @Ajmal_Yazdani ปีที่แล้ว +1

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

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

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

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว

      Of course, you can add those to make it more robust

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

  • @erdemozdemir5958
    @erdemozdemir5958 หลายเดือนก่อน

    Most complicated explanation i have ever seen.

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

  • @alaaalnajjar1824
    @alaaalnajjar1824 ปีที่แล้ว +1

    What is assigned to "ApplicationAssemblyReference" ?

  • @hellokaamds
    @hellokaamds ปีที่แล้ว +1

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

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

  • @GeoffSeeley
    @GeoffSeeley ปีที่แล้ว +2

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

  • @sunzhang-d9v
    @sunzhang-d9v ปีที่แล้ว +1

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

  • @dasdotnet1
    @dasdotnet1 ปีที่แล้ว +1

    This is Great

  • @mr-black_rock321
    @mr-black_rock321 23 วันที่ผ่านมา

    What happened when one of service failed in transaction Compensatory event?

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

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

  • @amitgoswami9591
    @amitgoswami9591 4 หลายเดือนก่อน

    which operating system are you using ?

    • @MilanJovanovicTech
      @MilanJovanovicTech  4 หลายเดือนก่อน

      Windows

    • @amitgoswami9591
      @amitgoswami9591 4 หลายเดือนก่อน

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

  • @ramytawfik9168
    @ramytawfik9168 ปีที่แล้ว

    can you recommend a good source of functional programming Milan ?

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว

      Zoran Horvat for TH-cam, 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 ?

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

  • @mr-black_rock321
    @mr-black_rock321 23 วันที่ผ่านมา

    Please make a video on failure

    • @MilanJovanovicTech
      @MilanJovanovicTech  22 วันที่ผ่านมา

      I did: th-cam.com/video/FPVzevl6Ri8/w-d-xo.html

    • @mr-black_rock321
      @mr-black_rock321 20 วันที่ผ่านมา

      @@MilanJovanovicTechAwesome thanks !

  • @AndreiDzimchuk
    @AndreiDzimchuk ปีที่แล้ว +1

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

  • @juancarlosbaezpozos9353
    @juancarlosbaezpozos9353 5 หลายเดือนก่อน +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  5 หลายเดือนก่อน +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 5 หลายเดือนก่อน

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

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

  • @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 5 หลายเดือนก่อน

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