Learn to set up the development environment and build an an end-to-end microservices application with .NET Core and Apache Kafka.

In This Series:

  1. Development Environment and Event Producer
  2. Event Consumer (this article)
  3. Azure Event Hubs Integration

Let’s carry our discussion forward and implement a consumer of the events published by the Employee service to the leave-applications Kafka topic. We will extend the application that we developed earlier to add two new services to demonstrate how Kafka consumers work: Manager service and Result reader service.

Source Code

The complete source code of the application and other artifacts is available in my  GitHub repository.

Consumer Example: Manager Service

The Manager service acts as both a consumer and a producer of events. The service reads the leave applications from the leave-applications topic (consumer), asynchronously records the manager’s decision on the application, and publishes the result as an event named leave application processed to the leave-applications-results Kafka topic (publisher).

Since we previously discussed the Publisher API and its implementation in the Employee service in detail in the previous article, I will not cover its event producer feature again. I encourage you to attempt building the publisher feature of the service using my version of the source code as a guide.

Launch your Visual Studio or VS Code to create a new .NET Core console application named TimeOff.Manager in the same solution as the Employee service. For reference, you can locate this project in the  GitHub repository with the same name.

As before, we will install the following NuGet packages to our project to enable our application to understand how to produce and consume messages:

PowerShell

Install-Package Confluent.Kafka
Install-Package Confluent.SchemaRegistry.Serdes.Avro

#cloud #tutorial #devops #aws #github

Event-Driven Architecture With Apache Kafka for .NET Developers Part 2: Event Consumer
1.15 GEEK