SC.Microservice.Kafka.Template 3.0.0

dotnet new install SC.Microservice.Kafka.Template::3.0.0                
This package contains a .NET Template Package you can call from the shell/command line.

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:

  1. Downloading and Installation Apache Kafka (kafka_2.13-3.5.0.tgz) from apache

  2. Extract the file "kafka_2.13-3.5.0.tgz" in [C:/kafka]

  3. Created folder name [C:/kafka/kafka-log] and [C:/kafka/zookeeper-data]

  4. Open file "zookeeper.properties" in [C:\kafka\kafka_2.13-3.5.0\config] dataDir=C:/kafka/zookeeper-data

  5. Open file "server.properties" in [C:\kafka\kafka_2.13-3.5.0\config] log.dirs=C:/kafka/kafka-log

  6. 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
  1. 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
  1. 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
  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

MIT

  • 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.

Version Downloads Last updated
3.0.0 2,622 12/13/2023
2.1.0 674 11/24/2023
2.0.0 282 9/8/2023
1.2.0 266 8/29/2023
1.1.0 291 8/28/2023