Book Image

Software Architecture with C# 12 and .NET 8 - Fourth Edition

By : Gabriel Baptista, Francesco Abbruzzese
3.5 (2)
Book Image

Software Architecture with C# 12 and .NET 8 - Fourth Edition

3.5 (2)
By: Gabriel Baptista, Francesco Abbruzzese

Overview of this book

Software Architecture with C# 12 and .NET 8 puts high-level design theory to work in a .NET context, teaching you the key skills, technologies, and best practices required to become an effective .NET software architect. This fourth edition puts emphasis on a case study that will bring your skills to life. You’ll learn how to choose between different architectures and technologies at each level of the stack. You’ll take an even closer look at Blazor and explore OpenTelemetry for observability, as well as a more practical dive into preparing .NET microservices for Kubernetes integration. Divided into three parts, this book starts with the fundamentals of software architecture, covering C# best practices, software domains, design patterns, DevOps principles for CI/CD, and more. The second part focuses on the technologies, from choosing data storage in the cloud to implementing frontend microservices and working with Serverless. You’ll learn about the main communication technologies used in microservices, such as REST API, gRPC, Azure Service Bus, and RabbitMQ. The final part takes you through a real-world case study where you’ll create software architecture for a travel agency. By the end of this book, you will be able to transform user requirements into technical needs and deliver highly scalable enterprise software architectures.
Table of Contents (26 chapters)
23
Answers
24
Other Books You May Enjoy
25
Index

Implementing worker microservices with ASP.NET Core

In order to avoid blocking the caller’s synchronous request for too much time, an ASP.NET Core-based solution requires the implementation of an internal queue where it can store all received messages. This way, when a message is received, it is immediately enqueued without processing it, so that a “received” response can be immediately returned.

Therefore, the application level needs a repository interface that handles the queue. Here is a possible definition of this interface:

public interface IMessageQueue
{
    public Task<IList<QueueItem>> Top(int n);
    public Task Dequeue(IEnumerable<QueueItem> items);
    public Task Enqueue(QueueItem item);
}

Where:

  • QueueItem is a class that contains all request information
  • Enqueue adds a new message to the queue
  • Top returns the first n queue items without removing them from the queue
  • Dequeue removes the first...