NET Microservices CQRS Event Sourcing with Kafka

Learn how to create microservices in C# that are based on CQRS and Event Sourcing. Powered by .NET and Apache Kafka.
NET Microservices CQRS Event Sourcing with Kafka
File Size :
3.05 GB
Total length :
8h 30m



Sean Campbell


Last update




NET Microservices CQRS Event Sourcing with Kafka

What you’ll learn

Event Sourcing
How to Create Microservices in C# with .NET
Creating DDD-Oriented Microservices
Using Apache Kafka as a Message Bus
Creating an Event Store with MongoDB
Optimistic Concurrency Control
Event Versioning
Using Microsoft SQL to Implement the Read Database
Replay the Event Store and Recreate the State of the Aggregate
Replay the Event Store and Recreate the Entire Read Database
Replay the Event Store and Recreate the Read Database in a Different Database Type – PostgreSQL
Implementing the Database-Per-Service Pattern
Entity Framework Core (MS SQL and PostgreSQL)
Dependency Injection

NET Microservices CQRS Event Sourcing with Kafka


Some experience with C# is essential


In this course, you will learn how to create .NET microservices that comply with the CQRS and Event Sourcing patterns.You will not use any CQRS framework, but you will write every line of code that is required to effectively create your own CQRS and Event Sourcing framework using C# and Apache Kafka. While this might sound a little daunting, you will be carefully guided step by step, and gain all the know-how and confidence to become an expert in CQRS and Event Sourcing.By the end of this course, you will know how to:Handle commands and raise events.Use the mediator pattern to implement command and query dispatchers.Create and change the state of an aggregate with event messages.Implement an event store / write database in MongoDB.Create a read database in MS SQL.Apply event versioning.Implement optimistic concurrency control.Produce events to Apache Kafka.Consume events from Apache Kafka to populate and alter records in the read database.Replay the event store and recreate the state of the aggregate.Separate read and write concerns.Structure your code using Domain-Driven-Design best practices.Replay the event store to recreate the entire read database.Replay the event store to recreate the entire read database into a different database type – PostgreSQL.The ultimate goal of this course is to take a deep-dive into the world of CQRS and Event Sourcing to enable you to create microservices that are super decoupled and extremely scalable.


Section 1: Introduction

Lecture 1 Microservices Basics

Lecture 2 CQRS

Lecture 3 Event Sourcing

Lecture 4 Architecture Overview

Lecture 5 Apache Kafka

Section 2: Setup & Structure

Lecture 6 Setup & Structure Section Intro

Lecture 7 Prerequisites

Lecture 8 Run Kafka in Docker

Lecture 9 Run MongoDB in Docker

Lecture 10 Run Microsoft SQL in Docker.

Lecture 11 Basic Project Setup

Lecture 12 Adding Project References

Lecture 13 Adding NuGet Packages

Lecture 14 Setup Debug Configurations (VS Code Only)

Section 3: Messages

Lecture 15 What is a Command?

Lecture 16 Commands

Lecture 17 What is an Event?

Lecture 18 Events

Section 4: Command Dispatching

Lecture 19 The Mediator Pattern

Lecture 20 ICommandDispatcher Interface (The Mediator)

Lecture 21 CommandDispatcher (The Concrete Mediator)

Section 5: Aggregate

Lecture 22 What is an Aggregate?

Lecture 23 AggregateRoot

Lecture 24 PostAggregate Part 1

Lecture 25 PostAggregate Part 2

Section 6: Event Store

Lecture 26 What is an Event Store?

Lecture 27 EventModel

Lecture 28 IEventStoreRepository Interface

Lecture 29 EventStoreRepository

Lecture 30 IEventStore Interface

Lecture 31 EventStore

Lecture 32 IEventSourcingHandler Interface

Lecture 33 EventSourcingHandler

Section 7: Command Handling

Lecture 34 The Mediator Pattern Continued

Lecture 35 ICommandHandler Interface (The Abstract Colleague)

Lecture 36 CommandHandler (The Concrete Colleague)

Lecture 37 Register Command Handlers

Section 8: Event Producer

Lecture 38 Kafka Producer

Lecture 39 EventProducer Interface & Implementation

Lecture 40 Producing an Event

Section 9: Domain Layer

Lecture 41 Important DDD Concepts

Lecture 42 Domain Entities

Lecture 43 IPostRepository Interface

Lecture 44 ICommentRepository Interface

Section 10: Read Database

Lecture 45 The Read Database

Lecture 46 DatabaseContext

Lecture 47 Programmatically Create DB & Tables on Startup

Lecture 48 PostRepository

Lecture 49 CommentRepository

Section 11: Event Handling

Lecture 50 Event Handling Introduction

Lecture 51 IEventHandler Interface

Lecture 52 EventHandler

Section 12: Event Consumer

Lecture 53 Kafka Consumer

Lecture 54 IEventConsumer Interface

Lecture 55 EventJsonConverter

Lecture 56 EventConsumer

Lecture 57 ConsumerHostedService

Section 13: Command Controllers

Lecture 58 Command Controllers Intro

Lecture 59 Data Transfer Objects

Lecture 60 NewPostController

Lecture 61 Creating a New Social Media Post

Lecture 62 EditMessageController

Lecture 63 Edit Message of a Social Media Post

Lecture 64 LikePostController

Lecture 65 Like a Social Media Post

Lecture 66 AddCommentController

Lecture 67 Add a Comment to a Social Media Post

Lecture 68 EditCommentController

Lecture 69 Edit a Comment on a Social Media Post

Lecture 70 RemoveCommentController

Lecture 71 Delete a Comment from a Social Media Post

Lecture 72 DeletePostController

Lecture 73 Deleting a Social Media Post

Section 14: Queries & Query Dispatching

Lecture 74 The Mediator Pattern (Query Dispatching)

Lecture 75 Social Media Queries

Lecture 76 IQueryDispatcher Interface (The Mediator)

Lecture 77 QueryDispatcher (The Concrete Mediator)

Section 15: Query Handling

Lecture 78 Query Handling Introduction

Lecture 79 IQueryHandler Interface (The Abstract Colleague)

Lecture 80 QueryHandler (The Concrete Colleague)

Lecture 81 Register Query Handlers

Section 16: Query Controller

Lecture 82 Query Controller Intro

Lecture 83 Data Transfer Objects

Lecture 84 PostLookupController Part 1

Lecture 85 PostLookupController Part 2

Lecture 86 Testing the PostLookupController

Section 17: A Powerful Ending

Lecture 87 Powerful Ending Intro

Lecture 88 Create Functionality to Restore the Read Database

Lecture 89 Restore the Entire Read Database

Lecture 90 Rapidly Change the Read Database Type

Lecture 91 Congratulations

Software Engineers,Software Architects

Course Information:

Udemy | English | 8h 30m | 3.05 GB
Created by: Sean Campbell

You Can See More Courses in the Developer >> Greetings from

New Courses

Scroll to Top