SC.Microservice.Kafka.Template
3.0.0
dotnet new install SC.Microservice.Kafka.Template::3.0.0
SC.Microservice.Kafka.Template
The application is written in the .Net - using .NET 8. This is solution template for creating Api following the principles of Clean Architecture. Create new project base on this template by setup Nuget package.
Installation
- Install the latest .NET 8 SDK.
- Install Java JDK 8.
- Install Apache Kafka lastest
Install the dotnet new template:
dotnet new install SC.Microservice.Kafka.Template::3.0.0
Create new project:
dotnet new sc-clean-kafka-sln -n MyProjectName
Technologies:
- ASP.NET 8
- Entity Framework Core 8
- MediatR
- AutoMapper
- MassTransit
- Confluent Kafka
- Serilog
Database :
Db type support SQLServer, MariaDB, PostgerSQL. The template is configured to use SQL Server by default. If you would prefer to use MariaDB or PostgerSQL, change "DatabaseType" in file: "appsettings.json"
Clean.API:
- Change ConnectionStrings in appsettings.json
Clean.Infrastructure:
- Create local database
- Open View : Package Manager Console (Visual Studio). Change Default project to "microservices\Application\Clean.Infrastructure"
- Run command:
PM> Update-database
Inventory.API:
- Change ConnectionStrings in appsettings.json
Inventory.Infrastructure:
- Create local database
- Open View : Package Manager Console (Visual Studio). Change Default project to "microservices\Inventory\Inventory.Infrastructure"
- Run command:
PM> Update-database
Kafka:
You need to create the following topic for the template:
- CleanCreateAuditTopic
- InventoryCreateAuditTopic
- CreateProductTopic
- EditProductPriceTopic
- EditProductQuantityTopic
Run Apache Kafka local:
Downloading and Installation Apache Kafka (kafka_2.13-3.5.0.tgz) from apache
Extract the file "kafka_2.13-3.5.0.tgz" in [C:/kafka]
Created folder name [C:/kafka/kafka-log] and [C:/kafka/zookeeper-data]
Open file "zookeeper.properties" in [C:\kafka\kafka_2.13-3.5.0\config] dataDir=C:/kafka/zookeeper-data
Open file "server.properties" in [C:\kafka\kafka_2.13-3.5.0\config] log.dirs=C:/kafka/kafka-log
Run command for start zookeeper-server (from folder C:\kafka\kafka_2.13-3.5.0):
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
- Open other window run command for start kafka-server (from folder C:\kafka\kafka_2.13-3.5.0):
.\bin\windows\kafka-server-start.bat .\config\server.properties
- Open other window run command for created topics:
.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --topic CreateProductTopic --create --partitions 3 --replication-factor 1
.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --topic EditProductPriceTopic --create --partitions 3 --replication-factor 1
.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --topic EditProductQuantityTopic --create --partitions 3 --replication-factor 1
.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --topic CleanCreateAuditTopic --create --partitions 3 --replication-factor 1
.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --topic InventoryCreateAuditTopic --create --partitions 3 --replication-factor 1
- Run command for show all topic active:
.\bin\windows\kafka-topics.bat --bootstrap-server=localhost:9092 --list
Support
If you are having problems, please let me know by nguyenson1303
License
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.