A Command Query Responsibility Separation / Event Sourcing architecture is a clear fit for a project I'm starting, which will see around a billion financial transactions a year related to people's health insurance cover. The key benefits are audit history, scalability, enforcing an asynchronous-compatible UI across a number of teams, splitting these transactions from the read database, easing the transmission of state to intermittently connected field offices via event queues, and coping with significant business logic change throughout the system lifetime.
However there are areas where CQRS/ES is going to be problematic, for example assigning a numeric ID to 100mn people, user security where eventual consistency is not acceptable. There are also areas of the system that are CRUD in nature and do not benefit from CQRS/ES. Finally we will have a large number of developers in different teams and companies and it would be good to have areas that do not require CQRS/ES competence. Is it possible to employ a hybrid approach, where some areas are not event sourced? Could we just synchronize the relevant tables on both read and write sides?
Do CQRS-architected aggregate entities simplify snapshot cache invalidation? Any event that updates an aggregate entity that might be cached could be listened for by an invalidator, and given aggregate entities are coarser-grained than relational entities and we can distinguish write events does this problem become solvable?
I'm expecting around a billion events a year and a need to track around 4 years of history. Can we snapshot and archive older events?
Are there degrees of event sourcing? For example one online store system AddLineItem event might include line item price per unit, but rely on the read side to pull and render the product name on the invoice. Another online store might include the name in the event data. How do you choose what to include in the event? In health insurance it might limit what 'what if' analyses can be run - if we haven't included the insured person's age we can't feasibly simulate policies that require it?
Is there an interesting way to model events about events? For example an administrator enters into the system that a product's price will change at some date in the future. I suppose the snapshot would be a price timeline. Could we instead add a post-dated ProductPriceChanged event? Could we fake such events when running 'what if' scenarios? (Such aggregates would have to be rarely changed, to avoid version number and concurrency detection issues.)
CQRS/ES is often claimed to make the system easier to adapt to future business process change. I understand the argument that commands listing events in ubiquitous language makes discussing and reconfiguring them easier, and event sourcing removes some of the rigidities of the RDBMS model. But won't any changes within an event will break the replay of events? With systems subject to change won't you end up with many versioned events? Eg, in an online store assessing whether a client is a Gold Card Holder by changing criteria? Can you snapshot everything? How would you post-date these changes? Similarly do you have to be careful with dependency injection that none of the dependencies injected can affect business logic, as otherwise you break replay?
Any idea why it is associated with the .NET world, with less popularity in other areas of the industry?
Huge thanks even for just reading.