Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In a correctly modeled CQRS domain, can a single command have multiple events?

Tags:

cqrs

Are there scenarios where a single command results in having multiple events in CQRS? Can anybody give an example for this?

I'm asking because aggregates are transactional boundaries, and the implementation of writing an aggregate depends on the answer to this question.

like image 862
Golo Roden Avatar asked Jan 24 '14 13:01

Golo Roden


People also ask

Are CQRS commands part of the domain model?

CQRS commands and the onion architectureCommands belong to the core domain (just like domain events). They play an important role in the CQRS architecture - they explicitly represent what the clients can do with the application. Just like events represent what the outcome of those actions could be.

What is a CQRS pattern?

CQRS stands for Command and Query Responsibility Segregation, a pattern that separates read and update operations for a data store. Implementing CQRS in your application can maximize its performance, scalability, and security.

What problem does CQRS solve?

CQRS is a popular architecture pattern because it addresses a common problem to most enterprise applications. Separating write behavior from read behavior, which the essence of the CQRS architectural pattern, provides stability and scalability to enterprise applications while also improving overall performance.


1 Answers

Yes, for example consider the command AssignUserToGroup. The domain logic checks if some groups the user belongs to are mutually exclusive with the new one and if so 2 events are published: UserLeftTheGroup and UserEnteredTheGroup.

like image 162
Bartłomiej Szypelow Avatar answered Sep 20 '22 14:09

Bartłomiej Szypelow