I was wondering how you are going about error handling and what some established best-practices are.
The early Axon Versions distinguished between different types of events. Now ists pretty much just one type.
Lets say I have an aggregate A, which handles command C.
Upon receiving the command C detects that the parameters given in C imply that this is an illegal action.
Overall, it would be simple to just apply(new ErrorEvent()). This would make it easy to handle the error in event listeners,
but it would persist the event in the event store.
I am currently torn between the ease of this and the resulting audit possibilities and the potential issues with accumulating
a lot of non-state changing events in the event store potentially costing a lot of storage (may result in a denial of service)
and harm aggregate load times.
Is it possible and meaningful to publish domain events which are not persisted by the aggregate ?
What are your thoughts on this from a “clean design” perspective?
Pragmatically I currently tend to just apply the error events and deal with any issues once this should become a problem in practice (“premature optimization is the root of all evil”, Knuth)