101
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
•
Traditional N-Layered
.
•
Domain-Driven Design N-layered
.
•
Clean Architecture
(as used with
eShopOnWeb
)
•
Command and Query
Responsibility Segregation
(CQRS).
•
Event-Driven Architecture
(EDA).
You can also build microservices with many technologies and languages, such as ASP.NET Core Web
APIs, NancyFx, ASP.NET Core SignalR (available with .NET Core 2 or later), F#, Node.js, Python, Java,
C++, GoLang, and more.
The important point is that no particular architecture pattern or style,
nor any particular technology, is
right for all situations. Figure 6-3 shows some approaches and technologies (although not in any
particular order) that could be used in different microservices.
Figure 6-3. Multi-architectural patterns and the polyglot microservices world
Multi-architectural pattern and polyglot microservices means you can
mix and match languages and
technologies to the needs of each microservice and still have them talking to each other. As shown in
Figure 6-3, in applications composed of many microservices (Bounded Contexts in domain-driven
design terminology, or simply “subsystems” as autonom
ous microservices), you might implement
each microservice in a different way. Each might have a different architecture pattern and use different
languages and databases depending on the application’s nature,
business requirements, and
priorities. In some cases, the microservices might be similar. But that is not usually the case, because
each subsystem’s context boundary and requirements are usually different.
102
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
For instance, for a simple CRUD
maintenance application, it might not make sense to design and
implement DDD patterns. But for your core domain or core business, you might need to apply more
advanced patterns to tackle business complexity with ever-changing business rules.
Especially when you deal with large applications composed by multiple subsystems, you should not
apply a single top-level architecture based on a single architecture pattern. For instance, CQRS should
not be applied as a top-level architecture for a
whole application, but might be useful for a specific set
of services.
There is no sil
ver bullet or a right architecture pattern for every given case. You cannot have “one
architecture pattern to rule them all.” Depending on the priorities of each microservice, you must
choose a
different approach for each, as explained in the following sections.
Creating a simple data-driven CRUD microservice
This section outlines how to create a simple microservice that performs create, read, update, and
delete (CRUD) operations on a data source.
Dostları ilə paylaş: