
Microservices Design Patterns in .NET
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
- Explore applying S.O.L.I.D development principles in developing a stable microservice application
- Use your knowledge to solve common microservice application design challenges
Book DescriptionAre you a developer who needs to fully understand the different patterns and benefits that they bring to designing microservices? If yes, then this book is for you. Microservices Design Patterns in.NET will help you appreciate the various microservice design concerns and strategies that can be used to navigate them. Making a microservice-based app is no easy feat and there are many concerns that need to be addressed. As you progress through the chapters of this guide, you'll dive headfirst into the problems that come packed with this architectural approach, and then explore the design patterns that address these problems. You'll also learn how to be deliberate and intentional in your architectural design to overcome major considerations in building microservices. By the end of this book, you'll be able to apply critical thinking and clean coding principles when creating a microservices application using.NET Core.What you will learn - Use Domain-Driven Design principles in your microservice design
- Leverage patterns like event sourcing, database-per-service, and asynchronous communication
- Build resilient web services and mitigate failures and outages
- Ensure data consistency in distributed systems
- Leverage industry standard technology to design a robust distributed application
- Find out how to secure a microservices-designed application
- Use containers to handle lightweight microservice application deployment
Who this book is forIf you are a.NET developer, senior developer, software architect, or DevOps engineer who wants to explore the pros and cons, intricacies, and overall implementation of microservice architecture, then this book is for you. You'll also get plenty of useful insights if you're seeking to expand your knowledge of different design patterns and supporting technologies. Basic experience with application and API development with.NET Core (2+) and C# will help you get the most out of this book.
All prices
More details
Person
Trevoir Williams is a software engineer and part-time lecturer. With a master's degree in computer science, he has spent over a decade teaching web, software, and database development courses. He also has extensive industry experience in web application development, Azure Cloud system, and server administration. He enjoys teaching IT and development courses and hopes to impart knowledge of the latest developments in industry standards and techniques to his students.
Content
- Working with the Aggregator Pattern
- Implementing the Chain of Responsibility Pattern (Synchronous Communication)
- Asynchronous Communication between microservices
- Working with the CQRS Pattern
- Applying Event Sourcing Patterns
- Handling Data for Each Microservice with Database Per Service Pattern
- Implement transactions across microservices using the Saga pattern
- Build a fault-tolerant and resilient system with the Circuit Breaker Pattern
- Performing Health Checks of your services
- Reviewing the implementation of API Gateway Pattern
- API Security with Bearer Tokens
- Microservice Container Hosting
- Implementing Centralized Logging for Microservices
- Wrapping it all up
Preface
Hello there! We are here to explore design and development patterns that we can leverage when building a microservice application with .NET. Microservice architecture involves separating a potentially complex application into smaller, more maintainable services that must work together. Essentially, we take one big application and break it down into smaller parts.
This approach introduces a fresh crop of complexities in the application's design since these now separate services need to collaborate to deliver a unified experience to the end user. As such, we need to understand the various drawbacks of this architectural approach and strategize on how we can address the various concerns.
We will focus on using .NET, given that Microsoft has a proven track record of releasing and supporting top-notch tooling and support for the most recent technologies that allow us to develop cutting-edge solutions. Some of the reasons we focus on development with .NET are as follows:
- Well maintained: Microsoft is constantly pushing the boundaries and introducing new ways to accomplish old things and new ways to implement solutions and increase productivity. It is a well-maintained, supported, and documented ecosystem.
- Performance: .NET increases its performance with each new release. Microservices must be as performant and responsive as possible to ensure that the end user's experience is as clean as possible.
- Cross-platform: .NET Core is cross-platform and can be deployed on virtually any technology stack. This reduces the limitations surrounding deploying and supporting services written using .NET technology.
- Support for various technologies: Each problem has a technology that helps us to implement a solution. .NET has support for many technologies, making it a great candidate for universal development needs.
We want to ensure that we understand the possibilities and strategies needed while developing an application based on microservices architecture. We will review the theory behind each problem and then explore the potential solutions and technologies that help us to implement the best possible solution to our challenges while developing a solution.
Who this book is for
This book is designed for .NET developers who wish to demystify the various moving parts of microservices architecture. To get the most out of the book, you should ideally fit into one of these categories:
- Team leads: Leaders who need to understand the various moving parts and the theory behind design decisions that need to be made
- Senior developers: Developers who need to appreciate how to guide the development efforts and implement complex blocks of code
- Intermediate .NET developers: .NET developers who have a working knowledge of the .NET ecosystem and want to dig deeper into developing more complex solutions
The overall content of this book will assist you in understanding the dynamics of microservices application design and assist you in reaching the next level of development.
What this book covers
Chapter 1, Introduction to Microservices - the Big Picture, looks at microservice architecture at a high level and seeks to understand some of the early problems we might encounter and explores design patterns that address them.
Chapter 2, Working with the Aggregator Pattern, explores how domain-driven design and the aggregate pattern lay the foundation for scoping requirements and the foundation of microservice design.
Chapter 3, Synchronous Communication between Microservices, explores how we make microservices communicate synchronously and the potential drawbacks of this method.
Chapter 4, Asynchronous Communication between Microservices, looks at asynchronous communication between services, which allows us to send data and move along, regardless of the availability or potential long runtime of the other microservices being called.
Chapter 5, Working with the CQRS Pattern, explores the CQRS pattern and why it is useful in microservices development.
Chapter 6, Applying Event Sourcing Patterns, discusses the intricacies of event sourcing and how we can implement this to ensure that our data between services stays in sync.
Chapter 7, Handling Data for Each Microservice with Database per Service Pattern, covers the best practices surrounding implementing different databases in different services.
Chapter 8, Implement Transactions across Microservices Using the Saga Pattern, explores the Saga pattern and how it helps us implement transactions across our microservices.
Chapter 9, Building Resilient Microservices, reviews implementing retry and exit strategy logic for more resilient communication between services.
Chapter 10, Performing Health Checks on Your Services, reviews how we can implement health checks in our ASP.NET Core APIs and why they are essential.
Chapter 11, Implementing API and BFF Gateway Patterns, dives into implementing API gateways, the backed for frontend pattern, and how they help us to create a robust microservices application.
Chapter 12, Securing Microservices with Bearer Tokens, reviews how bearer tokens can secure communications with each service.
Chapter 13, Microservice Container Hosting, explores containerization and how we can leverage containers to efficiently host our microservices.
Chapter 14, Implementing Centralized Logging for Microservices, explores the steps and best practices for aggregating logs from several services into one viewing area.
Chapter 15, Wrapping It All Up, discusses the key points from each chapter and highlights how each plays a role in developing a microservices application.
To get the most out of this book
You will need knowledge of API development using ASP.NET Core and basic database development knowledge. This book is best suited for intermediate-level developers looking to improve their understanding of development design patterns.
Software/hardware covered in the book
Operating system requirements
ASP.NET Core 6/7
Windows, macOS, or Linux
C# 9/10
Windows, macOS, or Linux
Docker
Windows, macOS, or Linux
Most examples are shown using NuGet package manager commands and Visual Studio 2022. These commands can be translated into dotnet CLI commands, which can be used on any operating system and with alternative IDEs to Visual Studio.
Download the example code files
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Microservices-Design-Patterns-in-.NET. If there's an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/dD3Jv.
Conventions used
There are several text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, commands, and keywords. Here is an example: "As it stands, our CreateAppointmentHandler will handle everything that is needed in the situation."
A block of code is set as follows:
public class AppointmentCreated : IDomainEvent { public Appointment { get; set; } public DateTime ActionDate { get; private set; }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: "Select System info from the Administration panel."
Tips or important notes
Appear like this.
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...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.
File format: ePUB
Copy protection: without DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Use a reader that can handle the file format ePUB, such as Adobe Digital Editions or FBReader – both free (see eBook Help).
- Tablet/Smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePUB works well for novels and non-fiction books – i.e., 'flowing' text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook does not use copy protection or Digital Rights Management
For more information, see our eBook Help page.