Skip to content

FlowDance: Enabling Compensating Transactions between Microservices

Notifications You must be signed in to change notification settings

olahallvall/FlowDance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlowDance

FlowDance aims to address several critical aspects in the context of microservices architecture. Let's delve into each of these goals:

Support Inter-service Communication Between Microservices (Database-per-Service Pattern): In a microservices architecture, each service often manages its own database. The Database-per-Service Pattern encourages this separation. By adopting this pattern, services can communicate with each other through well-defined APIs, avoiding direct database access. This approach enhances modularity, scalability, and isolation, allowing services to evolve independently.

Replacing Distributed Transactions Calls supported by MSDTC: MSDTC (Microsoft Distributed Transaction Coordinator) is commonly used for distributed transactions across multiple databases. However, MSDTC introduces complexity, performance overhead, and potential deadlocks. FlowDance proposes a shift towards synchronous RPC (Remote Procedure Call) communication. Services share a Correlation ID / Trace ID to track related requests across the system. Instead of distributed transactions, services coordinate their actions using synchronous calls, simplifying the architecture. While strong consistency is essential in some business cases, FlowDance aims to minimize the need for distributed transactions.

Moving Away from Strong Consistency to Eventual Consistency Using the Compensating Transaction (or Compensating Action) Pattern: In distributed systems, achieving strong consistency (ACID properties) across all services can be challenging. FlowDance embraces eventual consistency, where operations may temporarily yield inconsistent results. The Compensating Transaction Pattern comes into play when a step in a process fails. If a step cannot be fully rolled back (e.g., due to concurrent changes), compensating transactions undo the effects of previous steps. This pattern ensures that the system eventually converges to a consistent state, even after partial failures.

Documentation and Examples

For more info please see FlowDance.Documentation

Here are some sample apps FlowDance.Examples

You need

  • Visual Studio 2022 or later
  • Azure Functions Core Tools (Azure Functions Core Tools lets you develop and test your functions on your local computer)
  • RabbitMQ with Streams activted (rabbitmq-plugins enable rabbitmq_stream)

Inspiration

Get started

  • Install Docker Desktop and start it up.
  • Open a command prompt in the root folder of the repo/DockerExternalDep (where the docker-compose.yml file is) and run the commands:
  • // Not needed for now docker network create --driver bridge FlowDanceNetWork
  • docker-compose up -d
  • Wait until both RabbitMQ and SQL Server has started.
  • Run the commands:
  • docker exec rabbitmq rabbitmq-plugins enable rabbitmq_stream
  • docker exec rabbitmq rabbitmqadmin declare queue --vhost=/ name=FlowDance.SpanCommands durable=true
  • docker exec rabbitmq rabbitmqadmin declare queue --vhost=/ name=FlowDance.SpanEvents durable=true
  • docker exec -d mssql /opt/mssql-tools/bin/sqlcmd -S . -U SA -P "Admin@123" -Q "CREATE DATABASE [DurableDB] COLLATE Latin1_General_100_BIN2_UTF8"
  • docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S . -U sa -P "Admin@123" -Q "SELECT name FROM sys.databases"
  • Download and install Azure Functions Core Tools

About

FlowDance: Enabling Compensating Transactions between Microservices

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published