Reputation: 31
I have Application aggregate, it can handle commands like Register, Install, Uninstall, Hide, Show, ChangeOwner, Publish, CancelPublication... there is around 20 commands in Application aggregate. Each command checks invariants of Application for instance Application can be:
Application generates respective events when commands are valid. Events are handled by projections and process managers.
I have Application and Statistics projection - they handle events from Application aggregate, both projections are 100% based on events, so that projections can be totally deleted and rebuild from scratch. Application and Statistics projections are requested by users through http:get endpoint
Problem:
Now I have a request from business analytics to track when Application is Opened by potential customer. By Opening they understand that potential customer see Application projection details like (name, description, price, feature, benefits, number of installations, reviews...).
Now I wonder If I am allowed to create Open command in Application aggregate. It will not change aggregate state, invariants are irrelevant for it. This command is only needed because of Statistics projections.
Additional problem is that some Applications might be visited hundred times each day so it can generate enormous number of events to process when aggregate is load into memory.
Do You think that creating Open command in Application aggregate in order to emit Opened event is a good way to solve this?
Upvotes: 2
Views: 158
Reputation: 446
Can the Open command be denied by the Application aggregate? If it cannot, is it really a command?
We issue commands to aggregates in order to validate them, and potentially deny them, if the current state of the aggregate does not allow the command to be executed.
If the Open command cannot be denied, and you still are determined to solve the user-tracking with events, you could consider simply issuing an ApplicationOpened event, without issuing a command to the aggregate.
Another option could be to track user actions and statistics in a another system entirely, perhaps just adding rows to a database table.
Upvotes: 3