Golo Roden
Golo Roden

Reputation: 150624

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

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.

Upvotes: 8

Views: 1765

Answers (1)

Bartłomiej Szypelow
Bartłomiej Szypelow

Reputation: 2121

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.

Upvotes: 10

Related Questions