Saga Design pattern Spring Boot Microservices Interview Questions and Answers | Code Decode

2022 ж. 15 Қар.
67 592 Рет қаралды

In this video of code decode we have explained saga design pattern in Spring boot microservices.
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
openinapp.co/udemycourse
Course Description Video :
yt.openinapp.co/dmjvd
Why SAGA ??
We know that Design pattern gives solutions to common problems faced by us “THE DEVELOPERS”. So What problem is solved by this SAGA design pattern ?
The problem started as soon as we moved from Monolithic application to Microservice Architecture.
We will take example of Swiggy , zomato.
You
Choose your dishes,
Add them to Cart and checkout
Make Payment
Order gets Delivered
Our order is marked as completed after delivery is successful.
In monolithic it’s not a problem as we have 1 database , multiple Tables like Orders, Payments, Delivery Etc. Now in 1 Single Atomic transaction we can do all these steps and if payment fails, everything gets rolled back.
Now we moved to microservices architecture and Segregated the whole zomato or swiggy application to
Order service
Payment service
Delivery Service
Now your order service accepts your order, Payment service validates the payment done and Delivery service is responsible for delivery of your order to your home. When delivered successfully the orders is marked completed in the application. This is happy case.
Ever thought about the worst case Delivery is failed as no delivery partner was available. Your payment was done, Money got deducted and now No food. At Least we need to get the money back and Order must be marked as cancelled.
For this to happen we need a Transaction rollback . Transaction did get rolled back but only the scope of transaction was in Delivery service. The boundary for this transaction ended in Delivery service.
Ways to Implement SAGA?
There are two type of saga implementation ways
choreography
orchestration
What is Choreography Saga Pattern?
Choreography is a way to coordinate sagas where participants exchange events without a centralized point of control
With choreography, each microservices run its own local transaction and publishes events to message broker system and that trigger local transactions in other microservices.
Advantages of Choreography Saga Pattern?
Good for simple workflows that require few participants and don't need a coordination logic
Doesn't require additional service implementation and maintenance.
Doesn't introduce a single point of failure, since the responsibilities are distributed across the saga participants.
Disadvantages of Choreography Saga Design Pattern?
Workflow can become confusing when adding new steps, as it's difficult to track which saga participants listen to which commands.
There's a risk of cyclic dependency between saga participants because they have to consume each other's commands
What is Orchestration Saga Pattern?
Orchestration is a way to coordinate sagas where a centralized controller tells the saga participants what local transactions to execute.
The saga orchestrator handles all the transactions and tells the participants which operation to perform based on events.
Advantages of Orchestration Saga Pattern?
Good for complex workflows involving many participants or new participants added over time.
Suitable when there is control over every participant in the process, and control over the flow of activities.
Doesn't introduce cyclic dependencies, because the orchestrator unilaterally depends on the saga participants.
Saga participants don't need to know about commands for other participants. Clear separation of concerns simplifies business logic.
Disadvantages of Orchestration Saga Pattern?
Additional design complexity requires an implementation of a coordination logic.
There's an additional point of failure, because the orchestrator manages the complete workflow
Most Asked Core Java Interview Questions and Answers: • Core Java frequently a...
Advance Java Interview Questions and Answers: • Advance Java Interview...
Java 8 Interview Questions and Answers: • Java 8 Interview Quest...
Hibernate Interview Questions and Answers:
• Hibernate Interview Qu...
Spring Boot Interview Questions and Answers:
• Advance Java Interview...
Angular Playlist: • Angular Course Introdu...
SQL Playlist: • SQL Interview Question...
GIT: • GIT
Subscriber and Follow Code Decode
Subscriber Code Decode: kzhead.info?...
LinkedIn : / codedecodeyoutube
Instagram: / codedecode25
#sagadesingpattern #interviewquestions #codedecode

Пікірлер
  • Got many offers just in ten days. Your playlist is enough to clear any interviews.

    @balag2368@balag2368 Жыл бұрын
    • Many congratulations Bala 👏👏👏👏. Well done . Keep learning keep shining Man 👍👍👍

      @CodeDecode@CodeDecode Жыл бұрын
    • absolutely. I also got 2 offers.

      @hackstreet781@hackstreet7819 ай бұрын
    • Which companies

      @kartiksachdeva4196@kartiksachdeva41963 ай бұрын
    • Do you have experience before in JAVA or did you try as a fresher?

      @ysatyadivy@ysatyadivy3 ай бұрын
    • ​@@ysatyadivy If u need any help u can ping me i have 8yoe

      @kartiksachdeva4196@kartiksachdeva41962 ай бұрын
  • Awsome channel ma'am! You are clearing up all the concepts in half an hour or less, keep up the great work!

    Жыл бұрын
    • Thanks 🙂🙂

      @CodeDecode@CodeDecode Жыл бұрын
  • I have read alot about microservices. But this playlist Sums everything up. Thanks alot.

    @abdulmaliknurudeen7331@abdulmaliknurudeen73319 ай бұрын
    • Good to hear that Man 👍👍😊

      @CodeDecode@CodeDecode8 ай бұрын
  • Nice explanation and illustration, without wasting time. Great job!

    @sreejeshraj4800@sreejeshraj4800 Жыл бұрын
    • Thanks a lot Raj 👍👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Very nice video, started some months ago on a microservices architecture project. This video offered me another view of my proiect as well. Many thanks, really looking forward for the next ones! Many congratulations! Very good job, maybe an improvement could be also some more examples from the real world while explaining all of the concepts could help to understand everything better, like Kafka could be a good example in this video for instance which you already mentioned.

    @razvan-danielmihaescu1555@razvan-danielmihaescu1555 Жыл бұрын
    • Thanks. Sure👍👍 we will cover more real time examples👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Please keep up your great job!.. All your materials are not only for interview it helps us to enhance and improve our overall technical knowledge in a concise way. Hats off to all your efforts!..

    @mohammedsufi4649@mohammedsufi46494 ай бұрын
    • Thanks 😊😊

      @CodeDecode@CodeDecode4 ай бұрын
  • Superb! Every time I study learn from here, I feel lucky to discover this channel. This channel will surely cling the #1 best channel one day.

    @AshishSingh-rx4sq@AshishSingh-rx4sq Жыл бұрын
    • Means a lot to us Ashish 🙏🙏

      @CodeDecode@CodeDecode Жыл бұрын
  • Helped me to understand the topic quite easily. Great job! 👍😀

    @sonujain4768@sonujain47685 ай бұрын
    • Thanks Sonu 😊❤️

      @CodeDecode@CodeDecode5 ай бұрын
  • Several thanks to you madam. After listening to your vodcast, I think I must be able to crack one interview. You must be well trained tutor

    @user-fc7th5rw1z@user-fc7th5rw1z2 ай бұрын
    • Thanks 😊😊 many congratulations on cracking your interviews 👍👍

      @CodeDecode@CodeDecode2 ай бұрын
  • Thanks a lot for such a brief explanation. I was waiting for it from a long time back...😊👌👍

    @manojkumarpadhi2445@manojkumarpadhi2445 Жыл бұрын
    • M glad it helps 👍🙂

      @CodeDecode@CodeDecode Жыл бұрын
  • Thanks for this video. Expected one.... first like...

    @thiyamybabygirl2144@thiyamybabygirl2144 Жыл бұрын
    • Thanks a lot 🙂🙂👍👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Nice and able to understand with more clarity. Thanks for your video.🙏

    @sajeeshkumar4510@sajeeshkumar4510 Жыл бұрын
    • Thanks Sajeesh 🙂🙂👍👍

      @CodeDecode@CodeDecode Жыл бұрын
  • this video is not for learning , but getting the entire concept clear in just 20 mins.

    @user-gw2fc6bf4f@user-gw2fc6bf4f2 ай бұрын
  • Got to know today about your channel . I found its v helpful. I have started going through ur Playlist, its v good for today's market 👌. N ur way explanation is awesome. It would would very helpful if you do a simple project on this saga please . I was asked in recent interviews

    @truthreveal6521@truthreveal6521 Жыл бұрын
    • Thanks a lot 🙂🙂. Sure we will do that 👍👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Awesome explanation on Saga Design Pattern and its two types. I just have one question regarding the Drawback of Orchestration Pattern : Since it is a single point of failure and if it's down then no service can communicate with each other to let next participant know of executing its process, is there any solution to this drawback? And if not, then is Orchestration Pattern worth using in Microservices architecture where there can be hundreds to thousands of microservices ? Your answer on this would be really appreciated. Thanks!

    @jayjoshi1366@jayjoshi13664 ай бұрын
  • Just 1/2hr ago it was asked in interview. Thanks for sharing this wonderful video🤩✌

    @manoj47parmar@manoj47parmar Жыл бұрын
    • Thanks Manoj. M sure things will settle up soon 👍👍

      @CodeDecode@CodeDecode Жыл бұрын
    • @@CodeDecode Ya one day definitely with the support of #CodeDecode

      @manoj47parmar@manoj47parmar Жыл бұрын
    • 👍👍keep rocking Manoj 👍👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Good content on the MS Design Patterns.

    @abhishekgowlikar@abhishekgowlikar4 ай бұрын
    • Thanks

      @CodeDecode@CodeDecode4 ай бұрын
  • Can you please also describe Chreography and orchestration with coding examples, TIA

    @phanimc11211@phanimc11211 Жыл бұрын
  • Excellent explanation Ma'am, I loved the way you explain with real time example. Can you please also describe Chreography and orchestration with coding examples?

    @Atul_Shegokar@Atul_Shegokar Жыл бұрын
    • Sure Atul 👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Hey thank you for making such great videos.. please make videos for other three types of design patterns

    @santhoshr2497@santhoshr2497Ай бұрын
    • Sure 👍

      @CodeDecode@CodeDecodeАй бұрын
  • I was asked about Saga pattern in an interview but I was not aware about it, now in 20 minutes, I know what it is about. Thank you very much and keep making such videos. Can you also cover Jenkins in some video?

    @hackstreet781@hackstreet7819 ай бұрын
    • Thanks. Please participate in our give away Man also let us know your name. You have been our constant supporter. We would love to pay you back. Please add your email n name in the form we shared today in the video.

      @CodeDecode@CodeDecode9 ай бұрын
  • very very nice and clear explanation madam. thank you for your videos

    @shankark1664@shankark16644 ай бұрын
    • you are welcome shankar

      @CodeDecode@CodeDecode4 ай бұрын
  • great video thanks code decode

    @dummymail6029@dummymail6029Ай бұрын
    • 😊👍

      @CodeDecode@CodeDecodeАй бұрын
  • hi , this video is truely very good , please try making videos of CQRS and other design patterns of Microservices. Thanks

    @krishnalakshmi8896@krishnalakshmi88968 ай бұрын
    • Sure we will try to upload that video soon 👍

      @CodeDecode@CodeDecode8 ай бұрын
  • Thank you very much..pls add videos for other patterns also

    @layarichard6739@layarichard6739 Жыл бұрын
    • Sure Richard 👍👍🙂🙂

      @CodeDecode@CodeDecode Жыл бұрын
  • Hello Mam, You are doing an awesome job helping many people out there with clarity. Can you please do a video on J2EE design patterns

    @vidhyavd8385@vidhyavd8385 Жыл бұрын
    • kzhead.info/channel/PLyHJZXNdCXselvpjEhygQ9GlDQihtQj6i.html

      @CodeDecode@CodeDecode Жыл бұрын
    • Thanks a lot Vidhya👍👍🙂🙂

      @CodeDecode@CodeDecode Жыл бұрын
  • Very good explanation. thannks

    @zmxn007@zmxn0077 ай бұрын
    • Thanks 😊

      @CodeDecode@CodeDecode7 ай бұрын
  • Thank you very much .. 😊

    @rajenderprasad1193@rajenderprasad1193 Жыл бұрын
    • 🙂🙂👍👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Well explained

    @ruchajoshi1517@ruchajoshi1517 Жыл бұрын
    • Thanks Rucha 🙂

      @CodeDecode@CodeDecode Жыл бұрын
  • Very nicely explained. Hats off!! Pls create a video for CQRS design pattern as well.

    @arpanagrawal4264@arpanagrawal4264 Жыл бұрын
    • Thanks 👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Hi,This is really helpful. Can you please also describe Chreography and orchestration with coding examples?

    @komalsingh-vi2ur@komalsingh-vi2ur Жыл бұрын
    • Sure Komal 👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Thanks maam. Good one

    @akashsaha9366@akashsaha9366 Жыл бұрын
    • Thanks Akash 🙂🙂

      @CodeDecode@CodeDecode Жыл бұрын
  • Hi this is gokul here Its been long time it's nice explanation about saga Could you please create a video of the real code example of the same UI micro service Order microservice, payment microservice, delivery microservice That would be really good Thanks for the informative video

    @gokulaher2476@gokulaher24762 ай бұрын
  • Hi, I have a doubt, what if we're designing for Flight Tickets booking with 2 services booking and payment service, If we use Saga, booking will reduces #AvailableTickets count and then goes to payment service. Take a look at this Scenario: a. 2 requests Came into system and only 1 ticket left to book b. As per Saga, first request reduced #AvailableTickets to 0 and went ahead to payment service c. Meanwhile second request entered booking service and saw no tickets available and returns. d. first request failed at payment and rolled back #AvailableTickets to 1 So Saga supports only eventual consistency?

    @srndrpec@srndrpec Жыл бұрын
  • Hi am using undertow-core dependency in my springboot project. Jfrog is not showing any fix version. And xray violation is showing in jenkins. Pls help to solve undertow vulnerability issue. Pls suggests some solution. Thanks in advance

    @rslakshmicreation@rslakshmicreation Жыл бұрын
  • Hi, It was a wonderful explanation of the SAGA pattern👌👏👏. Considering the same example which you gave us, can you make a spring-boot coding example, which shows us how this is implemented in real-time? Please provide me the link if you have already done a video for that. Thanks in advance

    @PolaSantosh27@PolaSantosh27 Жыл бұрын
    • Same request from my side as well

      @bhavanadurga@bhavanadurga Жыл бұрын
  • please make a video for CQRS and Event sourcing Design patterns

    @karthiknainupatruni5022@karthiknainupatruni5022 Жыл бұрын
  • Orchestration Pattern is the Synchronous Communication right?

    @na2599@na25992 ай бұрын
  • Thankyou dear

    @tysonnfury9226@tysonnfury9226 Жыл бұрын
    • 🙂🙂

      @CodeDecode@CodeDecode Жыл бұрын
  • please add video from spring batch process excel file microservice

    @hamednikbakht9708@hamednikbakht9708 Жыл бұрын
    • Sure 👍👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Can you explain what is the difference between this transaction communication and microservices communication.

    @tysonnfury9226@tysonnfury9226 Жыл бұрын
  • what is interceptor and how to create own interceptor in microservices ? and one more thing how to implement saga approach

    @lovebranch-hemavasanth@lovebranch-hemavasanth Жыл бұрын
  • Good explanation, can you please add CQRS design patterns video with example?

    @omprakash-vq3wq@omprakash-vq3wq Жыл бұрын
    • Sure om 👍👍🙂🙂

      @CodeDecode@CodeDecode Жыл бұрын
  • Super akka

    @sivashankar-sx9ul@sivashankar-sx9ul4 ай бұрын
    • Thanks

      @CodeDecode@CodeDecode4 ай бұрын
  • Please add example for the above concept , as per theory able to understand but if u added the coding part ,it will be wonderful.

    @anandu06@anandu06 Жыл бұрын
    • Sure sure 👍👌

      @CodeDecode@CodeDecode Жыл бұрын
  • Please do a series of design patterns and their use in micro services…

    @jayakrishnathammana@jayakrishnathammana Жыл бұрын
    • Sure 😊👍👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Can you please create videos for other design patterns too? Thanks in advance.

    @sreejeshraj4800@sreejeshraj4800 Жыл бұрын
    • Sure 👍👍 we will do that 👍

      @CodeDecode@CodeDecode Жыл бұрын
  • 👍💯

    @rishiraj2548@rishiraj2548 Жыл бұрын
    • Thanks Rishi 👍👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Can you pls implement Spring boot application of it

    @bhavanadurga@bhavanadurga Жыл бұрын
  • If orchestration itself has its own problems then what is the solution?

    @user-ll6gt2nd9q@user-ll6gt2nd9q2 ай бұрын
  • Good one though but this video title is misleading saying interview question, it's SAGA tutorial only.

    @ArjunKumar-zu2kl@ArjunKumar-zu2kl Жыл бұрын
  • i have no clue on what swiggy or zomato sounds like uber or grub hub ?

    @jasonsgreen@jasonsgreen7 ай бұрын
  • Can we have any implementation for Saga... which is good to work with Distributed tx

    @mallesrao@mallesrao Жыл бұрын
    • Sure👍

      @CodeDecode@CodeDecode Жыл бұрын
  • Please can u add videos for CQRS pattern

    @vandanac2244@vandanac22449 ай бұрын
    • Sure 👍

      @CodeDecode@CodeDecode9 ай бұрын
  • Hi Mam, Hope you are doing good. I need a small suggestion. In one of recent interviews, i was asked how you maintain transaction in microservice applications. I mentioned exactly the same saga design pattern. Just next to that i got a ques, how have u implemented the saga pattern in the project realtime? How to answer this question. Any siggestion would be great or else if any realtime implementation video would be there it would be much more helpful. ThankYou💯

    @arpitsik4649@arpitsik4649 Жыл бұрын
    • There are 2 ways Arpit - 1) orchestrator 2) choreography That's how u implement it. Is it not covered in video Arpit?? Did I forget to mention it???

      @CodeDecode@CodeDecode Жыл бұрын
    • @@CodeDecode No no mam , you have mentioned both the points in the video. It was asked how you have implemented that specific choreography in your project. May be implementTion part they want to know. That was my concern. Can we describe the kafka implementTion in answer to the same question

      @arpitsik4649@arpitsik4649 Жыл бұрын
    • Ohh ok implementation is left. Correct Arpit . I completely forgot about that. Thanks a lot for reminder. We will try to upload implementation part 👍👍😇. Thanks 🙂🙂

      @CodeDecode@CodeDecode Жыл бұрын
    • @@CodeDecode thank you so much mam. Eagerly waiting for the implementation video. Coz I lost one interview just bcz for this implementation part. As I always say, you are doing a way better for us. Keep going mam.✨️

      @arpitsik4649@arpitsik4649 Жыл бұрын
    • @@CodeDecode Waiting for implementation part and cqrs pattern. Please continue your microservice series as it will help everyone to upskill with your way of teaching with practical examples as theortical sessions are few only

      @sajalmathur6003@sajalmathur6003 Жыл бұрын
  • very nice video. is it possible for you to take CQRS, EVENT SOURCING

    @anandnerurkar4471@anandnerurkar4471 Жыл бұрын
    • Sure Anand 👍👍

      @CodeDecode@CodeDecode Жыл бұрын
  • I have a set of questions on Microservices, could you please help me with them?

    @PrateekJain348@PrateekJain348 Жыл бұрын
    • Sure Prateek. Shoot👍

      @CodeDecode@CodeDecode Жыл бұрын
    • @@CodeDecode Below is the list of Questions. - Circuit breaker pattern in Microservices? - Constructor overloading with reference to Dependency injection? - We have a Json file and 2 microservices , 1st one is putting data in this JSON file and 2nd one is consuming data from this. How will you handle locking of the file? - Can we use SAGA to resolve distributed locking system? - Will SAGA help in case we read Json file for put and consume case? - What will heppen when we use POST to update the Data? - There might be a change PUT won't work, can we use POST in that case? - Application is incapable of processing PUT, Can we use POST to update data in Database ? - Advantage/Disadvantage of using post to update Data? - Distributed Locks in Spring-boot Microservice Environment?

      @PrateekJain348@PrateekJain34811 ай бұрын
  • Thanks for the content. Please create other design pattern videos like CQRS

    @sona7806@sona7806 Жыл бұрын
    • sure we will create it soon

      @CodeDecode@CodeDecode Жыл бұрын
  • Please show example for saga pattern .

    @shilpasah3388@shilpasah3388 Жыл бұрын
    • Sure Shilpa 👍🙂

      @CodeDecode@CodeDecode Жыл бұрын
  • Hello Mam I am searching for a Java job as a fresher and I am bit worried. Please guide me which topics should I learn from your videos ??

    @dhirajbindal7539@dhirajbindal7539 Жыл бұрын
  • Your money got deducted and you have no food 😁😁😁😁 3:36

    @indlasubramanyam8766@indlasubramanyam8766 Жыл бұрын
    • 🤪

      @CodeDecode@CodeDecode Жыл бұрын
  • There is much English rather than facts and knowledge

    @rakeshmishraLmp@rakeshmishraLmp7 ай бұрын
  • One question, using the orchestrator, is the orchestrator microservice required to have its own database too?

    @Satenc0@Satenc010 ай бұрын
  • Nicely explained 🫡 Can you make a demo for this one?

    @iammanishvb7332@iammanishvb7332 Жыл бұрын
    • Sure Manish 👍

      @CodeDecode@CodeDecode Жыл бұрын
KZhead