Skip to content

Ecommerce example using SAGA, Outbox Pattern, Debezium, Kafka, Kafka Connect

Notifications You must be signed in to change notification settings

dskora/quarkus-ecommerce

Repository files navigation

Quarkus Ecommerce

What are we doing here ?

  • Event-Driven Architecture

  • Domain Driven Design (DDD)

  • SAGA Pattern ( Distributed transaction ): process & rollback ( compensating transactions )

  • Outbox Pattern: Avoid dual-writes, no 2PC required using Kafka,Kafka Connect, Debezium, Outbox Event Router

  • Kafka Messaging Systems for SAGA Orchestration

  • Outbox CDC to kafka topics (Debezium)

Services

Service name Endpoint
Order service localhost:8084
Customer service localhost:8085
Payment service localhost:8086
Inventory service localhost:8087
Shipment service localhost:8088
Discovery service localhost:8089

Prerequisite

  • Framework: Quarkus 3.5.2
  • Language: Java 17
  • Build Tool: Gradle

Get Started

Setup environment

docker-compose up -d

Build projects

./gradlew

Start outbox connectors

Create outbox connectors

sh register-connectors.sh

Clean Up

Delete all connectors

sh delete-connectors.sh

Testing

Scenario

Register a new customer with credit
Set an inventory stock
Customer uses its own account credit to finalize an order

Events - CustomerCreated · ProductRegisteredInStock · (Saga Run) OrderCreated · ProductStockReserved · PaymentRequested · CustomerCreditReserved · PaymentCompleted · ShipmentRequested

e2e-test/customer-uses-account-credit.sh

ScreenShot 1

Scenario

Register a new customer with credit
Set an inventory stock
Customer exceeds its own account credit to finalize an order
Order is rejected

Events - CustomerCreated · ProductRegisteredInStock · (Saga Run) OrderCreated · ProductStockReserved · PaymentRequested · CustomerCreditLimitExceededEvent · PaymentCancelled · ProductStockRelesed · OrderRejected

e2e-test/customer-exceeds-account-credit.sh

ScreenShot 1

Scenario

Register a new customer with credit
Set an inventory stock
Product is out of stock
Order is rejected

Events - CustomerCreated · ProductRegisteredInStock · (Saga Run) OrderCreated · ProductOutOfStock · OrderRejected

e2e-test/product-out-of-stock.sh

ScreenShot 1