Member-only story

.NET 5 Event-Driven Microservice with Kafka and MongoDB

Ajaychoudhary
4 min readMay 22, 2021

--

Event Driven Architecture

INTRODUCTION

Most of the organizations are adopting microservices architecture as it improves agility, scalability, availability, reliability of the applications. Event-Driven microservices has also gained lot of popularity with availability of great streaming engines like Kafka and NO-SQL databases like MongoDB. Event-driven microservices provide great features like loosely coupled design and asynchronous processing which is also one of the core feature of microservices architecture.

In this example, we will create one .NET 5 based Web API which will be integrated with Kafka to support event streaming and No-SQL MongoDB to store information presents in events.

Prerequisite

  • VSCODE/Visual Studio or some .net code editor
  • .NET 5 or .NET Core > 2.1
  • Kafka Cluster on Confluent Cloud or local setup
  • MongoDB Cluster on Mongo Atlas or local setup

Creating .NET 5/Core API

In this scenario, we will create two rest endpoints, one to read reviews stored in MongoDB and one to post a review. When Users/Applications will invoke post review API, it will produce one message on Kafka. Consumer application (Background Service) will…

--

--

Ajaychoudhary
Ajaychoudhary

Written by Ajaychoudhary

Staff Engineer at Disney+ Hotstar

No responses yet