236
CHAPTER 6 | Tackle Business Complexity in a Microservice with DDD and CQRS Patterns
current state of the aggregates. The compensatory actions are part of a complex topic that will require
deep analysis from your side, which includes discussing it with the business user and domain experts.
In any case, you can choose the approach you need. But the initial deferred approach
—
raising the
events before committing, so you use a single transaction
—
is the simplest approach when using EF
Core and a
relational database. It’s easier to implement and valid in many business cases. It’s also the
approach used in the ordering microservice in eShopOnContainers.
But how do you actually dispatch those events to their respective event handlers? What’s the
_mediator
object you see in the previous example? It has to do with the techniques and artifacts you
use to map between events and their event handlers.
Dostları ilə paylaş: