All Projects → fedeoliv → microservices-transactions

fedeoliv / microservices-transactions

Licence: MIT license
Choreography-based sagas to maintain data consistency in a microservice architecture.

Programming Languages

java
68154 projects - #9 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to microservices-transactions

Xandra
Fast, simple, and robust Cassandra driver for Elixir.
Stars: ✭ 239 (+1095%)
Mutual labels:  cassandra
cassandra-prometheus
prometheus exporter for cassandra
Stars: ✭ 25 (+25%)
Mutual labels:  cassandra
casper
Yelp's internal caching proxy, powered by Nginx and OpenResty at its core
Stars: ✭ 81 (+305%)
Mutual labels:  cassandra
Morphl Community Edition
MorphL Community Edition uses big data and machine learning to predict user behaviors in digital products and services with the end goal of increasing KPIs (click-through rates, conversion rates, etc.) through personalization
Stars: ✭ 253 (+1165%)
Mutual labels:  cassandra
Troilus
Troilus is a Java client library for Cassandra.
Stars: ✭ 17 (-15%)
Mutual labels:  cassandra
cassandra-data-apis
Data APIs for Apache Cassandra
Stars: ✭ 18 (-10%)
Mutual labels:  cassandra
Alia
High performance Cassandra client for clojure
Stars: ✭ 224 (+1020%)
Mutual labels:  cassandra
crystal-cassandra
A Cassandra driver for Crystal
Stars: ✭ 20 (+0%)
Mutual labels:  cassandra
janusgraph-docker
Yet another JanusGraph, Cassandra/Scylla and Elasticsearch in Docker Compose setup
Stars: ✭ 54 (+170%)
Mutual labels:  cassandra
cassandra-exporter
Java agent for exporting Cassandra metrics to Prometheus
Stars: ✭ 59 (+195%)
Mutual labels:  cassandra
ecchronos
Ericsson distributed repair scheduler for Apache Cassandra
Stars: ✭ 22 (+10%)
Mutual labels:  cassandra
pipeline
PipelineAI Kubeflow Distribution
Stars: ✭ 4,154 (+20670%)
Mutual labels:  cassandra
cassandra-phantom
Cassandra + Phantom Example
Stars: ✭ 64 (+220%)
Mutual labels:  cassandra
Cstar
Apache Cassandra cluster orchestration tool for the command line
Stars: ✭ 242 (+1110%)
Mutual labels:  cassandra
cassandra-web
cassandra web ui
Stars: ✭ 61 (+205%)
Mutual labels:  cassandra
Cassandra Reaper
Software to run automated repairs of cassandra
Stars: ✭ 235 (+1075%)
Mutual labels:  cassandra
ecaudit
Ericsson Audit plug-in for Apache Cassandra
Stars: ✭ 36 (+80%)
Mutual labels:  cassandra
janusgraph-deployement
A dockerized environment For [JanusGraph + ElasticSearch + Cassandra + GraphExp]
Stars: ✭ 16 (-20%)
Mutual labels:  cassandra
battlestax
BattleStax is a stateful JAMStack game that is wholesome fun for the entire crew.
Stars: ✭ 32 (+60%)
Mutual labels:  cassandra
cassandra-exporter
Simple Tool to Export / Import Cassandra Tables into JSON
Stars: ✭ 44 (+120%)
Mutual labels:  cassandra

Choreography-based Saga Pattern: Data consistency in Microservices

This is a transaction management sample solution that demonstrates how to maintain data consistency across services in a microservices architecture by using Saga pattern.

Services are implemented through choreography-based sagas, which means that all participants are loosely coupled as they don't have direct knowledge of each other. Participants 'simply' subscribe to each other’s events and respond accordingly.

Architecture Overview

Architecture Overview

Architecture Components

  • The Order API is a Java/Spring Boot RESTful service with routes to create a new order and get details of an existing order.

  • The Order Service is a saga participant written in Java/Spring Boot that receives requests from the Order API. It starts local transactions with a distributed database (Datastax Cassandra) to create a new order or query info about an existing order. After the creation of these local transactions, it publishes order events to the message broker (Apache Kafka). Additionally, there is an event handler that subscribes to a Customer Topic to receive customer events.

  • The Customer API is a Java/Spring Boot RESTful service with a route to create a new customer.

  • The Customer Service is a saga participant written in Java/Spring Boot that receives requests from the Customer API. It starts local transactions with a distributed database (Datastax Cassandra) to create a new customer. After the creation of these local transactions, it publishes customer events to the message broker (Apache Kafka). Additionally, there is an event handler that subscribes to an Order Topic to receive order events.

Architecture Notes

  • It is not mandatory to use a highly scalable distributed NoSQL database (like Datastax Cassandra) for local transactions for each saga participant, you can use a SQL or NoSQL database of your choice.

  • It is not mandatory to use Apache Kafka as a message broker, you can use another one of your choice (like RabbitMQ, Azure Event Hub, etc).

Architecture: A Successful Scenario

Architecture Overview

  1. The Order Service creates an Order in a PENDING state and publishes an OrderCreated event.

  2. The Customer Service receives the OrderCreated event and attempts to reserve credit for that order. It publishes a CreditReserved event and the order state is still PENDING.

  3. The Order Service receives the CreditReceived event and changes the order state to APPROVED.

Architecture: A Failure Scenario

Architecture Overview

  1. The Order Service creates an Order in a PENDING state and publishes an OrderCreated event.

  2. The Customer Service receives the OrderCreated event and attempts to reserve credit for that order. It publishes a CreditLimitExceeded event and the order state is still PENDING.

  3. The Order Service receives the CreditLimitExceeded event and changes the order state to REJECTED.

Getting Started: Prerequisites

  • Java 8 (OpenJDK or Oracle JDK)
  • Docker for Windows or Linux

Building and Running: Order services

Running the Docker container

Go to src/order and build the application:

$ docker build -t order-api .
$ docker run -p 8080:8080 -t order-api

Next you can use the Order API through Swagger UI on http://localhost:8080/swagger-ui.html.

Running without Docker container

If you want to run services without Docker container, run this script on src/order:

./gradlew assemble

The script above will download Gradle automatically and will build the API. Now you can run the API with this command:

./gradlew build && java -jar order-api/build/libs/order-api-*.jar

Next you can use the Order API through Swagger UI on http://localhost:8080/swagger-ui.html.

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].