Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domain: changes to an Entity instance as a source of domain events #63

Open
lhaze opened this issue Sep 4, 2019 · 2 comments
Open

Domain: changes to an Entity instance as a source of domain events #63

lhaze opened this issue Sep 4, 2019 · 2 comments

Comments

@lhaze
Copy link
Collaborator

lhaze commented Sep 4, 2019

Elaborate and implement a simple approach in which Entities can support eventsourcing.

Part of #40

@lhaze
Copy link
Collaborator Author

lhaze commented Sep 1, 2020

@pedro2555

If I may. Domain events and sourced events (from eventsourcing) are completely opposite to each other. A sourced event describes a change to be done…

Firstly, thank you for your note, even when you have removed it. It has helped me to refine what I was thinking of opening this issue.
Secondly, I'm sorry you had to wait for the reply. I was on vacation after intensive work-time during COVID.
Thirdly, let me clarify what I had in mind.

By the topic of this issue, I meant how to connect eventsourced Entity with another eventsourced Entity using domain events. Yes, you're right when you say the two kinds of events have different purposes. Domain events are unquestionable messages about facts that already happened, a way to provide means of loosely coupling distant places of the system.

On the other hand, eventsourced events are internal detail of an entity implementation. They can and should be stopped when the operation is invalid or unreasonable. In terms of Event-Driven Architecture, they can be identified as Command pattern.

When I was creating this issue, I hadn't had that idea well-thought. I hadn't considered the distinction between domain events and commands. Now I see a Context Gateway pattern which servers as a translation middleware between domain events (preferably from the distant parts of the system) and local context's commands. Command handlers/interactions turn these commands into mutative operations of the local entity, which represents its inner state by an eventsourced event.

Although the picture I'm trying to describe may sound complicated, I have to take into account designs of significantly complex contexts -- I work on banking systems on a daily basis. On the other hand, every pattern besides basic ones (Interactor, Entity, eventsourced Event) is optional.

@pedro2555
Copy link

pedro2555 commented Sep 15, 2020

In terms of event sourcing. Process Managers and Sagas manage the translation you're talking about, they translate events into commands. Further more they also apply compensations for failed commands, or yet more commands; which in turn may generate more events and so on.

For cross context communications a canonical model of events and commands may prove useful in larger system, or even smaller ones.

You'll find long discussions about process manager and sagas and their differences, and with that a lot of disparity. From my, I should say small, experience the only diference is state. Sagas have no state; works fine.

@lhaze lhaze modified the milestones: 0.1, 0.2 Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Domain Tier
  
To do
Development

No branches or pull requests

2 participants