Comments (6)
what do you mean with 'lots of domain objects'? Do you mean lot of aggregates or several bounded context? Both?
from m-r.
I'm referring to aggregates.
from m-r.
One way could be what I Do: just host each aggregate type or stream type/category into an isolated microservice. Then subscribe a microservice to another as you need. Inside the microservice each aggregate instance (an object with its unique id that is hydrated by its own stream of events) handles inconming messages (events and/or commands) in its own thread. So all aggregate instances work asynchronously. I work with pesimistic lock for each aggregate instance, since it works independently from the other instances. It works just fine and it is quite fast. No concurrency exceptions, no retries for concurrency issues. And I save a memento/snapshot in-memory an in the database for each transaction.
It is not perfect, but is a way that is working for me.
Disclaimer: English is not my mother tongue.
from m-r.
@Narvalex,makes sense to process each aggregate in their respective threads.
What confuses me is how to gather all the aggregate ids that needs processing? Is is good idea to query from read model? Doesn't it break CQRS if we query from readmodel at command side? And more over since events are the single source of truth, read model may be stale, hence we may be processing undesired aggregates.
Let's say our application renews membership of all the users in the system every night (if user has agreed for auto renewal). Basically we need to query all the users whose membership has expired, and who as agreed for auto-renewal. In case of relational db, querying such user is a breeze, but in eventstore not so intuitive. Am I missing something? Hydrating every aggregate in eventstore just check if those aggregate satisfies our condition is also a no go.
from m-r.
A simple solution could be:
- An aggregate called 'MembershipRenewalManager" that is subscribed to 'AccountManager' aggregate events.
- Each time a new account is created the MembershipRenewallManager handles that event and adds the account and membership info to its own list and saves to a single stream. Yes. A single stream. An aggregate holds the entire stream of accounts, so it can have a list of it (a snapshot is very useful here).
- The system can each night send a single command "RenewAllApplicableMemberships" to that particular aggregate instance (the 'MembershipRenewalManager' aggregate). Then the aggregate re hydrates, handle the command and then publish a massive batch of events 'AMembershipShouldBeRenew'. All of that in a single transaction.
- The account aggregate is subscribed to the Renewall aggregate, so all applicable accounts reacts and the memebership is renewed.
This is just one way.
from m-r.
Thanks for the response :)
from m-r.
Related Issues (20)
- EventDescriptor purpose HOT 4
- Add LICENSE to repository HOT 2
- About FakeBus sample implementation and contracts for the registration HOT 13
- How to implement business rules? HOT 10
- Why do commands include the entity id when creating entities? HOT 34
- Event is mutable HOT 1
- Deactivate action should be POST
- Extraneous properties (and even class)? HOT 2
- Should configuration settings be eventsourced? HOT 1
- Use ReflectionMagic and get rid of InfrastructureCrap.DontBotherReadingItsNotImportant.cs HOT 2
- aggregate id and aggregate root HOT 16
- CQRS and CRUD misconception HOT 21
- Remove bus from projections HOT 1
- Test
- What is the semantic of the Version property in the Event class ?
- Regarding the class naming convention HOT 3
- InventoryItemRenamed: Can't for the life of me see where this is being handled HOT 2
- AggregateRoot version never updated HOT 9
- Why use DelegateAdjuster? HOT 1
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 m-r.