Skip to content

An asp.net project used to demonstrate how microservices communicate to achieve eventual consistency. An event-driven architecture to develop scalable decoupled systems.

Notifications You must be signed in to change notification settings

dagweg/Microservices.AspNetCore

Repository files navigation

Microservices.AspNetCore

Overview

A simple example project on how to create and communicate with microservices using AspNetCore.

microservices drawio

Technologies

  • AspNetCore 9.0
  • Docker
  • Docker Compose
  • Apache Kafka (Confluent)
  • Entity Framework Core
  • PostgreSQL

Setup

  1. Clone the repository & install the dependencies:
git clone https://github.com/dagweg/Microservices.AspNetCore.git
dotnet restore
pnpm install .\microservices.client
  1. Make sure you have Docker Desktop installed.
  2. Run Zookeeper and Kafka using Docker Compose on the file kafka.yml:
docker-compose -f .\Microservices.AspNetCore.AppHost\kafka.yml up -d
  1. While this is running, run the Aspire API project:
dotnet watch run --project .\Microservices.AspNetCore.AppHost\
  1. Run the Next.Js Client
pnpm dev .\microservices.client

Test the project by placing product orders and observing the value after a few seconds.

How it works

  1. Input a quantity and place an order. image
  2. This makes a POST request to the API, which publishes a message to the Kafka Broker. image
  3. The Product-Microservice has event-handlers running in the background that continually listen to OrderPlacedEvent. When it receives an event, it checks the stock quantity and updates the stock. Otherwise it produces an 'OrderRejectedEvent'. image image
  4. The Order-Microservice listens to either 'OrderCreatedEvent' or 'OrderRejectedEvent' and updates the order status accordingly. image
  5. Finally, the client updates the new stock. image

About

An asp.net project used to demonstrate how microservices communicate to achieve eventual consistency. An event-driven architecture to develop scalable decoupled systems.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published