Implementing Event Driven Microservices Architecture in NET 7 Develop event based distributed apps that can scale with ever changing business demands using C 11 and NET 7 1st Edition Garverick pdf download
Implementing Event Driven Microservices Architecture in NET 7 Develop event based distributed apps that can scale with ever changing business demands using C 11 and NET 7 1st Edition Garverick pdf download
https://ebookfinal.com/download/distributed-net-programming-in-vb-
net-1st-edition-tom-barnaby-auth/
https://ebookfinal.com/download/building-distributed-applications-
with-visual-basic-net-dan-fox/
https://ebookfinal.com/download/net-e-business-architecture-1st-
edition-et-al-david-burgett/
https://ebookfinal.com/download/essential-asp-net-with-examples-in-
visual-basic-net-1st-edition-fritz-onion/
https://ebookfinal.com/download/numerical-simulations-and-case-
studies-using-visual-c-net-1st-edition-shaharuddin-salleh/
https://ebookfinal.com/download/developing-web-applications-with-
visual-basic-net-and-asp-net-1st-edition-john-alexander/
https://ebookfinal.com/download/corporate-event-project-management-
the-wiley-event-management-series-1st-edition-william-otoole/
Implementing Event Driven Microservices Architecture in
NET 7 Develop event based distributed apps that can
scale with ever changing business demands using C 11 and
NET 7 1st Edition Garverick Digital Instant Download
Author(s): Garverick, Joshua;McIver, Omar Dean;
ISBN(s): 9781803232782, 1803232781
Edition: 1
File Details: PDF, 26.80 MB
Year: 2023
Language: english
Implementing Event-Driven
Microservices Architecture in .NET 7
Joshua Garverick
BIRMINGHAM—MUMBAI
Implementing Event-Driven Microservices Architecture
in .NET 7
Copyright © 2023 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted
in any form or by any means, without the prior written permission of the publisher, except in the case
of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express
or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable
for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and
products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot
guarantee the accuracy of this information.
ISBN 978-1-80323-278-2
www.packtpub.com
To my wife, Melissa, and daughter, Audrey, for bringing me inspiration and supporting me while I go
off and do things like write books.
– Josh Garverick
To my wife, Raegan, your love, support, and patience have made it possible for me to pursue my
passion. And to my children, Olivia, Maxwell, and Benjamin, who bring light to my life with every
new experience we share.
– Omar McIver
Contributors
Omar McIver is a Microsoft Certified Trainer and has more than 12 years of experience in developing
enterprise-grade applications in regulated and global retail industries. He specializes in cloud-native
development and application modernization. He is a certified Azure Solution Architect and FinOps
Practitioner. His Udemy course on Practical OAuth, OpenID, and JWT in C# .NET Core has a rating
of 4.5 stars. Omar continues to stay at the forefront of cloud-native development, with a keen focus
on cost optimization, performance tuning, and highly scalable microservice architectures.
About the reviewers
Mikhail Filippov works at JetBrains as the team lead of Rider (cross-platform IDE for .NET).
During 20 years of software development experience, Mikhail got deep technical expertise in various
areas, including .NET runtime internals, ASP.NET MVC, MSBuild, and best practices for designing
large-scale development infrastructures. Mikhail is a speaker at multiple events for developers and
an active open source contributor. In his free time, Mikhail likes reading science fiction books and
working on hobby projects using C# and Kotlin.
Jamie Taylor is a Microsoft MVP, software engineer, mentor, and podcaster with over a decade and
a half of experience working with the .NET technology stack.
His primary focus is on his family, who inspire him every day. With a background in teaching, he
focuses his energies on mentoring, writing incredibly high-quality code, and sharing his knowledge
with everyone who will listen.
Outside of development and mentoring, Jamie is a keen podcaster - hosting three incredibly successful
podcasts: The .NET Core Podcast, Tabs and Spaces, and The Waffling Taylors - and has collaborated
with musicians, creating music and playing the bass guitar on a few recorded pieces.
Table of Contents
Prefacexv
2
The Producer-Consumer Pattern 21
Technical requirements 22 The producer code 26
Examining producers and consumers 22 The consumer code 29
Event handling 33
Relating to real-world examples 22
Enabling event-driven architectures 24 Reviewing implementation
Understanding the adoption curve 25 details in infrastructure 34
Exploring implementation Topics34
details in code 25 Streams and tables 35
viii Table of Contents
3
Message Brokers 39
Technical requirements 40 Message delivery patterns 45
What is a message broker? 40 Implementing message broker
Queue-based technology 40 technologies46
Cache-based technology 41 Reviewing essential Kafka components 47
Stream-based technology 42 Enabling resiliency and scalability 51
Inspecting messaging protocols, Summary53
schemas, and delivery patterns 43 Questions53
Messaging protocols 43
Further reading 54
Standard and custom schemas 44
4
Domain Model and Asynchronous Events 55
Technical requirements 56 Notifications66
Solution structure 56 Passenger68
Core library review 57 Identification70
6
Localized Testing and Debugging of Microservices 95
Technical requirements 96 Fixing the Debug custom image 109
Configuring orchestration and Testing against containers 110
containers96 Functionality testing 111
Everything as Code (EaC) 97 Load testing 113
Creating container images 97
Summary116
Debugging in containers 101 Questions116
Debugging individual microservices 102
Further reading 117
Orchestrating and debugging all services 104
7
Microservice Observability 119
Technical requirements 120 Traces122
Observability120 Liveness and readiness 123
Metrics121 Liveness endpoints 124
Logs122 Readiness endpoints 128
x Table of Contents
8
CI/CD Pipelines and Integrated Testing 147
Technical requirements 148 GitHub Actions for continuous integration 151
Reviewing common CI/CD patterns 148 GitHub Actions for continuous deployment 153
9
Fault Injection and Chaos Testing 159
Technical requirements 160 Implementing fault injection and
Fault tolerance and fault injection 160 chaos tests 162
Anticipating and tolerating faults 161 Starting with Chaos Mesh 163
Using your faults against you 161 Using Azure Chaos Studio 169
11
Minimizing Data Loss 195
Technical requirements 196 Methods of data loss 200
Preventing data loss 196 Delivery guarantees 201
Data consistency paradigms 197 At-most-once delivery 202
ACID paradigm/immediate consistency 197 At-least-once delivery 206
BASE paradigm / eventual consistency 197 Effectively-once delivery 208
The Saga pattern 199
Data loss implications 213
Command query responsibility
segregation (CQRS) 199 Summary214
Questions214
Identifying acceptable data loss 200
Further reading 214
Acceptable and unacceptable data loss 200
xii Table of Contents
12
Service and Application Resiliency 217
Technical requirements 218 Graceful communication
Resiliency through cloud-native between services 232
patterns218 Common results 233
Redundancy and enabling Summary236
business continuity 223 Questions237
Event retries and continuity 224
Further reading 237
Local data redundancy 225
Infrastructure continuity 231
13
Telemetry Capture and Integration 239
Technical requirements 240 Bubbling up meaningful information 247
Application- versus service- versus Metric ingestion with the Prometheus exporter 247
component-level telemetry 240 Distributed tracing using the Jaeger exporter 249
14
Observability Revisited 255
Technical requirements 256 Service discovery/registration 270
Sharing API services 256 Service resolution 273
Assessments283
Chapter 1, The Sample Application 283 Chapter 8, CI/CD Pipelines
Chapter 2, The Producer-Consumer and Integrated Testing 287
Pattern284 Chapter 9, Fault Injection
Chapter 3, Message Brokers 285 and Chaos Testing 287
Chapter 4, Domain Model Chapter 10, Modern Design Patterns
and Asynchronous Events 285 for Scalability 288
Chapter 5, Containerization Chapter 11, Minimizing Data Loss 289
and Local Environment Setup 285 Chapter 12, Service and
Chapter 6, Localized Testing Application Resiliency 289
and Debugging of Microservices 286 Chapter 13, Telemetry Capture
Chapter 7, Microservice Observability 286 and Integration 290
Chapter 14, Observability Revisited 290
Index291
Chapter 3, Message Brokers, covers details and implementation methods related to the use of message
brokers within the larger ecosystem of the application. The term “message broker” will be defined,
examples of technologies that act as message brokers will be discussed, and evaluations will be made
to facilitate the choice of the appropriate technology to address the needs of the application.
Chapter 4, Domain Model and Asynchronous Design, covers the details of the domain model, including
commands and events. It also covers the implementation of asynchronous events and when to use
them within the application.
Chapter 5, Containerization and Local Environment Setup, examines how containerization is used to
isolate functionality for build and deployment, and how to set up your local environment to enable
this workflow.
Chapter 6, Localized Testing and Debugging of Microservices, takes your local environment further,
building upon the environment setup and addition of the Dockerfile. You will learn how to test and
debug your microservice in your local environment.
Chapter 7, Microservice Observability, reviews different types of observability at the service level,
frameworks and technologies that enable observability, and how greater observability can be helpful
in the application’s ecosystem for both developers and operations.
Chapter 8, CI/CD Pipelines and Integrated Testing, reviews common continuous integration (CI) and
continuous delivery (CD) strategies, practical implementations using GitHub Actions, and how to
integrate baseline and regression testing into your pipelines.
Chapter 9, Fault Injection and Chaos Testing, reviews the concepts of fault tolerance and fault injection
as it relates to software testing. More complex testing methods, such as stress and chaos testing, will
be examined and you will learn how these techniques can be implemented to validate resilience and
fault tolerance.
Chapter 10, Modern Design Patterns for Scalability, reviews different design patterns that aim to enable
service scalability, as well as cover implementing scalability constructs in two popular deployment
targets (Kubernetes and Azure API applications).
Chapter 11, Minimizing Data Loss, teaches specific techniques for minimizing or eliminating data loss
as a result of scaling operations or as a function of increased service resiliency. Paradigms such as
eventual consistency and guaranteed delivery will be reviewed along with a refresher on identifying
data that may be susceptible to loss and defining how much if any, loss is acceptable.
Chapter 12, Service and Application Resiliency, helps you implement patterns, from what you’ve learned
about scalability and data loss, that will guarantee service uptime, business continuity, and end-user
satisfaction. Part of ensuring a consistent experience is generating meaningful messages to the end
user which can be handled in a variety of methods.
Preface xvii
Chapter 13, Telemetry Capture and Integration, examines different options for capturing application-
level and service-level telemetry, and how to ensure that relevant information is captured without
producing unnecessary noise or overhead. You will also learn how to pinpoint meaningful telemetry
and aggregate that as opposed to aggregating everything, which can lead to confusion, large storage
footprints, and a distrust of the information captured.
Chapter 14, Observability Revisited, in this chapter, you will learn about methodologies for publishing
service metadata to your organization, cataloging and versioning microservice metadata, and how to
promote the discovery of shared services within an organization.
If you are using the digital version of this book, we advise you to type the code yourself or access
the code from the book’s GitHub repository (a link is available in the next section). Doing so will
help you avoid any potential errors related to the copying and pasting of code.
Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file
extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “The
Zookeeper configuration is not shown as it is identical to the first docker compose file.”
A block of code is set as follows:
using OpenTelemetry.Metrics;
using OpenTelemetry;
using System.Diagnostics.Metrics;
Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words
in menus or dialog boxes appear in bold. Here is an example: “Be sure to uncheck the Use controllers
checkbox to use minimal APIs if using the new project dialog from Visual Studio.”
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at customercare@
packtpub.com and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen.
If you have found a mistake in this book, we would be grateful if you would report this to us. Please
visit www.packtpub.com/support/errata and fill in the form.
Preface xix
Piracy: If you come across any illegal copies of our works in any form on the internet, we would
be grateful if you would provide us with the location address or website name. Please contact us at
[email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you
are interested in either writing or contributing to a book, please visit authors.packtpub.com.
CAPITULO III
A REFORMA NO TEMPO DE ISABEL
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookfinal.com