Comments (6)
You're aggregate root has a certain state (derived from the history of events if you're doing event sourcing). Based on the state the method call on the AR will either fail or succeed?
If you're using the DBAL event store, it will throw an exception if the same playhead gets inserted twice (for one id), that probably covers your "problem"? :)
from broadway.
Let me explain:
In the Model Reading I keep the version of the aggregat linked to the last event.
User 1 : creates a aggregat (version 0).
User 1 and 2 : load the view for the aggregat (version 0).
User 2 : change the aggregat by a command indicating that the aggregat must be version 0. (change version from 0 to version 1)
User 1 : changes aggregat by a command indicating that the aggregat must be version 0. Changes can not be made because it is based on data been deprecated.
I do not know if I express myself well. It is to avoid this "problem" I ask this question;-)
So what's the best solution?
from broadway.
I'd have to think about a "nice" way of doing this, but I'm wondering if you really need this? Do you have an example of your actual domain? What are the chances of this happening? What would the cost of such an error be?
As said before, if two processes are committing at the same time, only one of them will be able to save the events as of this moment.
from broadway.
I have an application where the risk of competition between two users is very high.
Another solution would be to check the event happened between the two versions (current and those notified in the order) to block similar commands.
Otherwise, the last command to the last word!
The concurrency is very difficult to manage.
If a command overwrites the previous amendment, I must provide a means to reapply the changes overwritten.
from broadway.
👎
I think you need to deal with this yourself. Perhaps some sort of process manager that detects concurrent events and initiates merging? Perhaps you need a different model? I'm just thinking out loud here.
from broadway.
It's true. Thank for your help !
from broadway.
Related Issues (20)
- drop test/Broadway/TestCase
- make PHPUnit a dependency HOT 5
- test the test helpers with examples HOT 2
- Built-in asynchronous way to run processors? HOT 3
- Example/explanation on event sourcing for aggregate roots HOT 1
- What is the overall state of the project? Is it GDPR ready? HOT 2
- Simple Command Bus - Manage Throwable exceptions
- Could you do a new release? HOT 2
- Are there any plans to update broadway? HOT 1
- Asymmetry between EventBus interface and EventListener interface HOT 2
- Broadway does not seem to survive hot upgrades HOT 2
- duck-typing vs interface HOT 1
- Replaying events to rebuild elastic search index HOT 1
- PHP 8 support HOT 2
- Processor after projector HOT 2
- Aggregator HOT 3
- Indirect development dependency used in src ConcurrencyConflictResolvers
- no recent tags? HOT 1
- Get uncommitted events without empty the aggregate HOT 4
- Give serializers flexibility to map based on event type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from broadway.