SlideShare a Scribd company logo
Microservices
BankNext’s -Event Driven- SAGA Compensation
Business Objective
• “BankNext” employed event driven choreography & achieved high processing efficiencies as described
in architecture-as-is
• However, when reconciling customer & account information, abnormal system behavior was noticed
• Problem scenarios -
• Dangling Customers - Active Customers without any valid Account
• Linkage not created - Valid Customers and Accounts present but linkage between these entities is missing
• How did this happen ? Let’s investigate
Current Event-Driven w/o SAGA
Back to the Drawing Board
• BankNext’s event driven system is composed of multiple msvcs that independently manage data
persistence
• If any of the msvcs in this transactional flow fail, then there is no provision to correct/rollback the
data that was already persisted by an upstream msvc
• This was the root cause of severe data integrity problems in the system
Technical Challenge
• The “CustomerMgt” msvc successfully creates the customer entity in the “customer” table in the RDBMS
• Next, “AccountMgt” msvc creates the account entity in the “account” DB table , after receiving the subscription on the
Kafka topic
• In the last step, “EntityAggregation” msvc links these 2 entities by creating an entry in to the “customer_account_map”
table in the RDBMS
• The process is considered successful if & only if the above 3 steps are atomic i.e. Either all 3 steps complete successfully or
none complete
• If/when the “AccountMgt” or “EntityAggregation” msvc fails for any reason then the data integrity problems occur
Scenarios
1. Example scenario
i. Customer entity created successfully.
ii. Account Msvc fails the request per the business validation rule
iii. eg. only “SAVINGS” & “CURRENT” allowed but “OVERDRAFTS” received
iv. Account entity creation aborts.
v. Consequence - Customer is left without an Account. Thus Dangling Customer.
2. Example scenario
i. Customer entity created successfully.
ii. Account entity created successfully.
iii. EntityAggregation Msvc fails the request per the business validation rule
iv. eg. for “USA” only type allowed is “SAVINGS” but “CURRENT” received
v. Customer and Account linking aborts.
vi. Consequence - Active Customer and Account is created but they are not linked
Solution Approach
SAGA compensation
1. In such a failure scenario, the solution requires that all the data persisted by upstream msvcs be rolled back
2. Thus the system data can be brought back to the state that it was before this txn started
3. SAGA approach is recommended to accomplish this task
SAGA Architecture
Technical Implementation (contd..)
SAGA compensation
1. New Kafka topics are created for capturing messages in case of failure scenarios -
i. customer_failure_topic
ii. account_failure_topic
iii. entitymap_failure_topic
2. When a msvc fails, a message is published to the corresponding failure topic
3. When “AccountMgt” publishes to the “account_failure_topic”,
i. “CustomerMgt” which is subscribed to this topic, gets notified
ii. DB rollback activity initiated.
4. When “EntityAggregation” publishes to the “entitymap_failure_topic”,
i. “AccountMgt” & “CustomerMgt” which is subscribed to this topic gets notified
ii. DB rollback activity initiated
5. Thus SAGA compensation accomplishes txn atomicity and restores the original system state
SAGA Interactions – Closer Look
State of the Database
SAGA-Customer-Rollback
State of the Database
SAGA-Account-Rollback
State of the Database
Customer-Account-Integration-Success
New Architecture Positives
1. SAGA enables robustness and graceful system integrity restoration
2. Provides a sturdy & flexible mechanism to accomplish process atomicity
3. Eliminates tight coupling via publish & subscribe, as needed
New Architecture Negatives
1. SAGA adds to system complexity and maintenance
2. Observability, system debugging and tracing capabilities need to be significantly ramped up
3. There is a danger that the rollback operation triggered by the SAGA may itself fail.
4. Retries may be needed in such scenarios which further complicates matters
Summary : Architecture, TechStack & Rationale
Github : https://github.com/vijayredkar/event-driven-platform-with-saga
Architecture Goal Strategy Techstack Rationale
Flexible & extensible integrations Choreography Topics Eliminates centralized coordinator dependency
Event driven capability Messaging systems Kafka Eliminates tight coupling btwn svcs
Transactional system data integrity SAGA Topics - failure capture Self healing system recovery
Future capability efficiencies Publish/Subscribe Kafka Eliminates explicit new svc call invocation
System wide observability Centralized logging/tracing ELK/Sleuth Async logging & observability
Heavy volume/TPS Streaming Kafka/Async operations Extremely low latency
Parallel Aggregation CompletableFuture Java General purpose
Framework microservices Springboot General purpose
Transactional Durability Persistence RDBMS (H2 for demo) General purpose
Thank you!
-Vijay Redkar
Github: https://github.com/vijayredkar
Medium: https://vijayredkar.medium.com/
vijay0512@yahoo.com
+971 588823757

More Related Content

PDF
Event Sourcing in less than 20 minutes - With Akka and Java 8
PPTX
Saga about distributed business transactions in microservices world
PDF
Maintaining Consistency for a Financial Event-Driven Architecture (Iago Borge...
PDF
Digital Transformation with Kubernetes, Containers, and Microservices
PDF
20160317 lagom sf scala
PDF
Workflows via Event driven architecture
PDF
Effective Akka v2
PPTX
Event Sourcing in less than 20 minutes - With Akka and Java 8
Saga about distributed business transactions in microservices world
Maintaining Consistency for a Financial Event-Driven Architecture (Iago Borge...
Digital Transformation with Kubernetes, Containers, and Microservices
20160317 lagom sf scala
Workflows via Event driven architecture
Effective Akka v2

What's hot (20)

PDF
A practical introduction to Event Sourcing and CQRS
PDF
Reactive Architectures
PPTX
Cqrs + event sourcing pyxis v2 - en
PDF
Cloudstate - Towards Stateful Serverless
PPTX
Ratpack and Grails 3 GR8Conf US 2014
PPTX
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014
PDF
Microservice Architecture with CQRS and Event Sourcing
PPTX
Microservices Journey Fall 2017
PDF
Modern Software Architecture - Cloud Scale Computing
PPTX
How ddd, cqrs and event sourcing constitute the architecture of the future
PDF
Building data-driven microservices
PPTX
Our Journey To Continuous Delivery
PPTX
CQRS and Event Sourcing, An Alternative Architecture for DDD
PPTX
Designing microservices
PDF
How we eased out security journey with OAuth (Goodbye Kerberos!) | Paul Makka...
PPTX
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
PDF
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
PDF
Microservices, Kubernetes, and Application Modernization Done Right
PDF
Lowering the risk of monolith to microservices
PDF
"What database can tell about application issues? What application can tell a...
A practical introduction to Event Sourcing and CQRS
Reactive Architectures
Cqrs + event sourcing pyxis v2 - en
Cloudstate - Towards Stateful Serverless
Ratpack and Grails 3 GR8Conf US 2014
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014
Microservice Architecture with CQRS and Event Sourcing
Microservices Journey Fall 2017
Modern Software Architecture - Cloud Scale Computing
How ddd, cqrs and event sourcing constitute the architecture of the future
Building data-driven microservices
Our Journey To Continuous Delivery
CQRS and Event Sourcing, An Alternative Architecture for DDD
Designing microservices
How we eased out security journey with OAuth (Goodbye Kerberos!) | Paul Makka...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Microservices, Kubernetes, and Application Modernization Done Right
Lowering the risk of monolith to microservices
"What database can tell about application issues? What application can tell a...
Ad

Similar to Microservices event-driven-saga (20)

PPTX
Microservices - Event-driven & the hidden landmines
PPTX
Event driven architecure
PDF
Jim Killian\'s SQL Server 2008 Portfolio
PPTX
Secret Techniques to Manage Apache Cloudstack with ActOnCloud
DOCX
Software Engineering Testing & Research
PPT
SQL Server 2008 Portfolio for Saumya Bhatnagar
PPTX
Building a SaaS based product in Azure - Challenges and decisions made
PDF
DBMS GATE Notes for computer science.pdf
PPT
Weighbridge PPT
PDF
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
PPTX
Kakfa summit london 2019 - the art of the event-streaming app
PDF
The art of the event streaming application: streams, stream processors and sc...
PDF
Kafka summit SF 2019 - the art of the event-streaming app
PPTX
Microservices in Action: putting microservice-based applications into production
PPTX
Data Design and Modeling for Microservices I AWS Dev Day 2018
PDF
Building a SaaS Style Application
PDF
Sybase BAM Overview
PDF
Scaling managed MySQL Platform in Flipkart - (Sachin Japate - Flipkart) - Myd...
PPT
Reduce Payroll Errors
PDF
Sage Intacct Integration with Bill.com A Comprehensive Guide.pdf
Microservices - Event-driven & the hidden landmines
Event driven architecure
Jim Killian\'s SQL Server 2008 Portfolio
Secret Techniques to Manage Apache Cloudstack with ActOnCloud
Software Engineering Testing & Research
SQL Server 2008 Portfolio for Saumya Bhatnagar
Building a SaaS based product in Azure - Challenges and decisions made
DBMS GATE Notes for computer science.pdf
Weighbridge PPT
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
Kakfa summit london 2019 - the art of the event-streaming app
The art of the event streaming application: streams, stream processors and sc...
Kafka summit SF 2019 - the art of the event-streaming app
Microservices in Action: putting microservice-based applications into production
Data Design and Modeling for Microservices I AWS Dev Day 2018
Building a SaaS Style Application
Sybase BAM Overview
Scaling managed MySQL Platform in Flipkart - (Sachin Japate - Flipkart) - Myd...
Reduce Payroll Errors
Sage Intacct Integration with Bill.com A Comprehensive Guide.pdf
Ad

Recently uploaded (20)

PDF
Download FL Studio Crack Latest version 2025 ?
PPTX
CHAPTER 2 - PM Management and IT Context
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
history of c programming in notes for students .pptx
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
assetexplorer- product-overview - presentation
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
Cost to Outsource Software Development in 2025
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Download FL Studio Crack Latest version 2025 ?
CHAPTER 2 - PM Management and IT Context
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
history of c programming in notes for students .pptx
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Odoo Companies in India – Driving Business Transformation.pdf
Digital Systems & Binary Numbers (comprehensive )
Oracle Fusion HCM Cloud Demo for Beginners
assetexplorer- product-overview - presentation
Operating system designcfffgfgggggggvggggggggg
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
iTop VPN Crack Latest Version Full Key 2025
Designing Intelligence for the Shop Floor.pdf
Weekly report ppt - harsh dattuprasad patel.pptx
Cost to Outsource Software Development in 2025
Wondershare Filmora 15 Crack With Activation Key [2025
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx

Microservices event-driven-saga

  • 2. Business Objective • “BankNext” employed event driven choreography & achieved high processing efficiencies as described in architecture-as-is • However, when reconciling customer & account information, abnormal system behavior was noticed • Problem scenarios - • Dangling Customers - Active Customers without any valid Account • Linkage not created - Valid Customers and Accounts present but linkage between these entities is missing • How did this happen ? Let’s investigate
  • 4. Back to the Drawing Board • BankNext’s event driven system is composed of multiple msvcs that independently manage data persistence • If any of the msvcs in this transactional flow fail, then there is no provision to correct/rollback the data that was already persisted by an upstream msvc • This was the root cause of severe data integrity problems in the system
  • 5. Technical Challenge • The “CustomerMgt” msvc successfully creates the customer entity in the “customer” table in the RDBMS • Next, “AccountMgt” msvc creates the account entity in the “account” DB table , after receiving the subscription on the Kafka topic • In the last step, “EntityAggregation” msvc links these 2 entities by creating an entry in to the “customer_account_map” table in the RDBMS • The process is considered successful if & only if the above 3 steps are atomic i.e. Either all 3 steps complete successfully or none complete • If/when the “AccountMgt” or “EntityAggregation” msvc fails for any reason then the data integrity problems occur
  • 6. Scenarios 1. Example scenario i. Customer entity created successfully. ii. Account Msvc fails the request per the business validation rule iii. eg. only “SAVINGS” & “CURRENT” allowed but “OVERDRAFTS” received iv. Account entity creation aborts. v. Consequence - Customer is left without an Account. Thus Dangling Customer. 2. Example scenario i. Customer entity created successfully. ii. Account entity created successfully. iii. EntityAggregation Msvc fails the request per the business validation rule iv. eg. for “USA” only type allowed is “SAVINGS” but “CURRENT” received v. Customer and Account linking aborts. vi. Consequence - Active Customer and Account is created but they are not linked
  • 7. Solution Approach SAGA compensation 1. In such a failure scenario, the solution requires that all the data persisted by upstream msvcs be rolled back 2. Thus the system data can be brought back to the state that it was before this txn started 3. SAGA approach is recommended to accomplish this task
  • 9. Technical Implementation (contd..) SAGA compensation 1. New Kafka topics are created for capturing messages in case of failure scenarios - i. customer_failure_topic ii. account_failure_topic iii. entitymap_failure_topic 2. When a msvc fails, a message is published to the corresponding failure topic 3. When “AccountMgt” publishes to the “account_failure_topic”, i. “CustomerMgt” which is subscribed to this topic, gets notified ii. DB rollback activity initiated. 4. When “EntityAggregation” publishes to the “entitymap_failure_topic”, i. “AccountMgt” & “CustomerMgt” which is subscribed to this topic gets notified ii. DB rollback activity initiated 5. Thus SAGA compensation accomplishes txn atomicity and restores the original system state
  • 10. SAGA Interactions – Closer Look
  • 11. State of the Database SAGA-Customer-Rollback
  • 12. State of the Database SAGA-Account-Rollback
  • 13. State of the Database Customer-Account-Integration-Success
  • 14. New Architecture Positives 1. SAGA enables robustness and graceful system integrity restoration 2. Provides a sturdy & flexible mechanism to accomplish process atomicity 3. Eliminates tight coupling via publish & subscribe, as needed
  • 15. New Architecture Negatives 1. SAGA adds to system complexity and maintenance 2. Observability, system debugging and tracing capabilities need to be significantly ramped up 3. There is a danger that the rollback operation triggered by the SAGA may itself fail. 4. Retries may be needed in such scenarios which further complicates matters
  • 16. Summary : Architecture, TechStack & Rationale Github : https://github.com/vijayredkar/event-driven-platform-with-saga Architecture Goal Strategy Techstack Rationale Flexible & extensible integrations Choreography Topics Eliminates centralized coordinator dependency Event driven capability Messaging systems Kafka Eliminates tight coupling btwn svcs Transactional system data integrity SAGA Topics - failure capture Self healing system recovery Future capability efficiencies Publish/Subscribe Kafka Eliminates explicit new svc call invocation System wide observability Centralized logging/tracing ELK/Sleuth Async logging & observability Heavy volume/TPS Streaming Kafka/Async operations Extremely low latency Parallel Aggregation CompletableFuture Java General purpose Framework microservices Springboot General purpose Transactional Durability Persistence RDBMS (H2 for demo) General purpose
  • 17. Thank you! -Vijay Redkar Github: https://github.com/vijayredkar Medium: https://vijayredkar.medium.com/ vijay0512@yahoo.com +971 588823757