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 the largest open marketplace for online courses on the internet. Founded in 2010 by Eren Bali, Oktay Caglar, and Gagan Biyani and headquartered in San Francisco, the company went public on the Nasdaq in 2021 under the ticker UDMY. The platform hosts well over two hundred thousand courses across software development, IT and cloud, data science, design, business, marketing, and creative skills, taught by tens of thousands of independent instructors. Roughly seventy million learners use it worldwide, and the corporate arm — Udemy Business — supplies a curated subset of that catalog to enterprise customers.

Because Udemy is a marketplace rather than a single editorial publisher, the catalog is uneven by design. The strongest material lives in the long-form, project-based courses authored by working engineers — full-stack JavaScript, React, Node.js, Python data science, AWS, Docker and Kubernetes, mobile development with Flutter and React Native, and cloud certification preparation. The CourseFlix listing under this source is the slice of that catalog that has been mirrored here for offline-friendly viewing, organized by topic and updated as new releases land. Pricing on Udemy itself swings dramatically with the site's near-permanent sales, which is why the platform is best treated as a deep reference catalog: pick instructors with strong reviews and a track record of updating their material rather than buying on the headline price alone.

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

Course content

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

Related courses

  • Design Patterns in C# and .NET thumbnailFree

    Design Patterns in C# and .NET

    By: Udemy
    Learn design patterns in C#. You see clear steps to use each pattern in .NET. This course helps you write clean code with proven design ideas.
    20 hours 15 minutes 1 second 5 / 5

Frequently asked questions

What is .NET Microservices: CQRS & Event Sourcing with Kafka about?
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…
Who teaches .NET Microservices: CQRS & Event Sourcing with Kafka?
.NET Microservices: CQRS & Event Sourcing with Kafka is taught by Udemy. You can find more courses by this instructor on the corresponding source page.
How long is .NET Microservices: CQRS & Event Sourcing with Kafka?
.NET Microservices: CQRS & Event Sourcing with Kafka contains 91 lessons with a total runtime of 8 hours 31 minutes. All lessons are available to watch online at your own pace.
Is .NET Microservices: CQRS & Event Sourcing with Kafka free to watch?
.NET Microservices: CQRS & Event Sourcing with Kafka is part of CourseFlix's premium catalog. A CourseFlix subscription unlocks the full video player; the course description, table of contents, and preview information are available to everyone.
Where can I watch .NET Microservices: CQRS & Event Sourcing with Kafka online?
.NET Microservices: CQRS & Event Sourcing with Kafka is available to watch online on CourseFlix at https://courseflix.net/course/net-microservices-cqrs-event-sourcing-with-kafka. The page hosts every lesson with the integrated video player; no download is required.