Skip to main content
CourseFlix

.NET Microservices: CQRS & Event Sourcing with Kafka

8h 31m 56s
English
Paid

This course teaches you how to build .NET microservices with CQRS and Event Sourcing. You write the full code yourself. You use C#, MongoDB, SQL Server, and Kafka. You learn each idea step by step so you can use these patterns with confidence.

What You Will Learn

You build each part of the system. You see how commands, events, and data flow work together. You also learn how the read and write paths stay apart.

CQRS and Event Flow

  • Handle commands and raise events.
  • Use the mediator pattern for command and query dispatch.
  • Change aggregate state with event messages.
  • Apply event versioning and track changes over time.
  • Replay events to rebuild an aggregate state.

Data Stores and Persistence

  • Build an event store as the write side in MongoDB.
  • Create the read side in SQL Server.
  • Use optimistic concurrency control.
  • Replay all events to rebuild the full read database.
  • Rebuild the read database in a new type, such as PostgreSQL.

Kafka Integration

  • Produce events to Apache Kafka.
  • Consume Kafka events to update the read database.

Why These Skills Matter

You learn how to keep read and write paths separate. This leads to clean code and clear flow. You also see how event logs help you fix errors and rebuild data.

By the end, you know how to build microservices that scale and stay easy to change.

About the Author: udemy

udemy thumbnail

Udemy is a global online marketplace for teaching and learning. It connects students with instructors who share skills in many fields.

Who Uses Udemy

Millions of learners use Udemy to gain skills for work and personal growth. Companies, governments, and nonprofits also use Udemy to train their teams.

What Udemy Offers

Udemy provides a curated set of business and technical courses. These courses help teams build practical skills and support ongoing learning at work.

Watch Online 91 lessons

This is a demo lesson (10:00 remaining)

You can watch up to 10 minutes for free. Subscribe to unlock all 91 lessons in this course and access 10,000+ hours of premium content across all courses.

View Pricing
0:00
/
#1: Microservices Basics
All Course Lessons (91)
#Lesson TitleDurationAccess
1
Microservices Basics Demo
03:52
2
CQRS
02:27
3
Event Sourcing
01:22
4
Architecture Overview
06:50
5
Apache Kafka
01:04
6
Setup & Structure Section Intro
00:27
7
Prerequisites
08:09
8
Run Kafka in Docker
05:39
9
Run MongoDB in Docker
02:34
10
Run Microsoft SQL in Docker.
05:07
11
Basic Project Setup
08:59
12
Adding Project References
10:21
13
Adding NuGet Packages
05:21
14
Setup Debug Configurations (VS Code Only)
02:52
15
What is a Command?
00:55
16
Commands
05:01
17
What is an Event?
00:32
18
Events
08:23
19
The Mediator Pattern
03:11
20
ICommandDispatcher Interface (The Mediator)
02:47
21
CommandDispatcher (The Concrete Mediator)
05:33
22
What is an Aggregate?
02:17
23
AggregateRoot
09:51
24
PostAggregate Part 1
12:27
25
PostAggregate Part 2
08:21
26
What is an Event Store?
01:04
27
EventModel
03:23
28
IEventStoreRepository Interface
02:34
29
EventStoreRepository
09:17
30
IEventStore Interface
01:21
31
EventStore
11:27
32
IEventSourcingHandler Interface
01:43
33
EventSourcingHandler
06:56
34
The Mediator Pattern Continued
00:46
35
ICommandHandler Interface (The Abstract Colleague)
01:55
36
CommandHandler (The Concrete Colleague)
10:07
37
Register Command Handlers
05:09
38
Kafka Producer
03:19
39
EventProducer Interface & Implementation
10:02
40
Producing an Event
05:34
41
Important DDD Concepts
01:26
42
Domain Entities
05:28
43
IPostRepository Interface
03:47
44
ICommentRepository Interface
01:47
45
The Read Database
00:27
46
DatabaseContext
09:34
47
Programmatically Create DB & Tables on Startup
07:44
48
PostRepository
08:27
49
CommentRepository
05:03
50
Event Handling Introduction
00:21
51
IEventHandler Interface
01:43
52
EventHandler
09:43
53
Kafka Consumer
03:40
54
IEventConsumer Interface
00:39
55
EventJsonConverter
07:49
56
EventConsumer
11:58
57
ConsumerHostedService
06:36
58
Command Controllers Intro
00:39
59
Data Transfer Objects
01:25
60
NewPostController
08:30
61
Creating a New Social Media Post
15:05
62
EditMessageController
05:33
63
Edit Message of a Social Media Post
12:09
64
LikePostController
03:25
65
Like a Social Media Post
10:57
66
AddCommentController
03:07
67
Add a Comment to a Social Media Post
11:25
68
EditCommentController
03:20
69
Edit a Comment on a Social Media Post
12:12
70
RemoveCommentController
04:24
71
Delete a Comment from a Social Media Post
11:09
72
DeletePostController
02:57
73
Deleting a Social Media Post
10:21
74
The Mediator Pattern (Query Dispatching)
01:03
75
Social Media Queries
03:37
76
IQueryDispatcher Interface (The Mediator)
03:34
77
QueryDispatcher (The Concrete Mediator)
05:45
78
Query Handling Introduction
00:23
79
IQueryHandler Interface (The Abstract Colleague)
01:45
80
QueryHandler (The Concrete Colleague)
04:29
81
Register Query Handlers
04:25
82
Query Controller Intro
00:18
83
Data Transfer Objects
01:14
84
PostLookupController Part 1
09:59
85
PostLookupController Part 2
09:00
86
Testing the PostLookupController
16:49
87
Powerful Ending Intro
00:41
88
Create Functionality to Restore the Read Database
12:28
89
Restore the Entire Read Database
20:06
90
Rapidly Change the Read Database Type
14:06
91
Congratulations
00:25
Unlock unlimited learning

Get instant access to all 90 lessons in this course, plus thousands of other premium courses. One subscription, unlimited knowledge.

Learn more about subscription