Comments (2)
Hi. There are several ways to ensure idempotency with CQRSlite.
The first and perhaps simplest is to use the included versioning and optimistic concurrency to make sure the user works on the newest data. If two of the same commands where to be sent, things would throw out of order exception because the version was not as expected.
The second and more complicated way is to make sure all commands are idempotent. This would require a command like AddProduct to have a value like number of productsInCart instead of numberOfProducts added.
A third approach is to save the command stream and create a unique id when creating a command, and making sure that command is not already applied when you get it. This is not supported directly, so you have to extend the framework to find a good solution. If you do find a good solution to it, I'm interested in seeing how I could make this into the framework if it would make any sense.
I'm sure there are several other ways as well, but if you can try optimistic concurrency as it by far the simplest way. It's also built into CQRSlite, so it requires very little effort.
from cqrslite.
Hi, sorry didn't reply earlier here. To clarify you meant optimistic concurrency on command level all they way from the user's UI? That is a great safe guard to keep Aggregates valid and would be enough in most cases, I agree. I will see if I can get away with this.
In some situations it might be nice for the application to "know" if certain command succeeded (instead of seeing concurrency error), especially if user has little time to review and act on error (for example player registering scores in between points on watch: IWon, ILost commands). Things might get more complicated if multiple registrants might exists (if both players register scores for the same match).
from cqrslite.
Related Issues (20)
- Concurrency errors HOT 7
- Error EventIdIncorrectException in the new version HOT 2
- Snapshot aggregte returns an aggregate with default values. HOT 8
- Another article about CQRSlite HOT 1
- Where are the query and event handlers being registered? HOT 1
- Not sure if this is a bug or intentional... HOT 3
- Question about events and new commands HOT 4
- How to "rollback" to a specific version? HOT 2
- Are async handlers waited? HOT 1
- Untyped Save<T> when calling from Session HOT 2
- Project maintained?
- How to handle the version property in react or angular frontend? HOT 3
- Aggregate may change identity during history load HOT 5
- You can no longer return IServiceProvider from ConfigureServices as in Web example from .NET Core 3 HOT 9
- Implement snapshot HOT 4
- DSL for CQRSlite HOT 3
- Service fabric doesn't support GenericHostBuilder HOT 5
- Entity Framework Problem HOT 6
- Add netstandard2.1 and correct dependencies to match the standards HOT 4
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 cqrslite.