Skip to content

Implementation of the Saga pattern for the classic trip booking example

Notifications You must be signed in to change notification settings

koniecznyp/trip-booking-saga

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trip-booking-saga

The main purpose of the created application is to deepen knowledge in the field of microservice orchestration and system design using the saga pattern. The Saga pattern describes how to solve distributed (business) transactions without two-phase-commit as this does not scale in distributed systems. The basic idea is to break the overall transaction into multiple steps or activities. Only the steps internally can be performed in atomic transactions but the overall consistency is taken care of by the Saga. The Saga has the responsibility to either get the overall business transaction completed or to leave the system in a known termination state. So in case of errors a business rollback procedure is applied which occurs by calling compensation steps or activities in reverse order. You can find more information about Sagas here Saga: How to implement complex business transactions without two phase commit or Transactions and Failover using Saga Pattern in Microservices Architecture

Application consists of microservices:

  • Reservations.Api - API Gateway
  • Reservations.Services.CarsRental - Car reservation service
  • Reservations.Services.Hotels - Hotel reservation service
  • Reservations.Services.Flights - Flights reservation service
  • Reservations.Transactions - Distributed transaction management service

Technology stack:

I encourage you to track the entire flow using debug mode. You can experimentally modify the code and throw, for example, an exception in places where the logic of flight or hotel booking is included, and then follow the cancellation process from the saga. The most important part of the system is TripReservationSaga.cs, which contains the logic of the booking process and supports rollback in case of failure. The entire process is tracked using Jaeger. The event log related to each step of the operation is available at http://localhost:16686/

About

Implementation of the Saga pattern for the classic trip booking example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages