This repository houses a prototype project focused on exploring event-driven architecture using Apache Kafka and its integration with ASP.NET microservices. The goal is to provide a hands-on environment for learning how to build scalable and reactive systems.
Ensure you have the following installed:
- .NET 8.0 SDK
- Docker Desktop (for running Kafka and Zookeeper)
Follow these steps to get the project up and running:
-
Clone the Repository:
git clone https://github.com/abdullahoday710/Kafka-dotnet-CAP cd Kafka-dotnet-CAP
-
Start Docker Services: Start the necessary Kafka and Zookeeper and postgres containers:
docker-compose up -d
The
-d
flag runs the containers in detached mode, so they run in the background.TIP : to see all your running detached docker instances you can use the command
docker container ls
-
populate the databases
Now we need to create the tables for our database, Simply run these commands
update-database -Project BillingService -StartupProject BillingService
update-database -Project OrderService -StartupProject OrderService
-
Run a Microservice:
-
Using Visual Studio: Open the
KafkaCAPPlayground.sln
file in Visual Studio. You can then select and run any of the individual microservices within the solution. -
Using the .NET CLI: From the root directory, you can run the default
OrderService
microservice directly:dotnet run --project OrderService/OrderService.csproj
-
- Add a migration to a specific microservice :
add-migration {Migration name} -Project {Microservice name} -StartupProject {Microservice name}
- Update the database for a specific microservice :
update-database -Project {Microservice name} -StartupProject {Microservice name}