mbnx
mbnx

Reputation: 942

CQRS: Update Read-Model without Event Sourcing

We have built a CQRS-based system using a relational DB on the domain-side and a NoSQL DB on the read-side. The domain-side follows a classical, relational approach while the read-side is denormalized. Data replication and transformation is done using events emitted by command handlers.

I have two questions regarding read-side synchronization:

_

interface IReadModelBuilder<TEntity>
{
    //// Returns a sequence of events which replicate the read-model 
    //// when executed by the event handlers.
    Event[] GetReplicationSequence(TEntity instance);
}

END OF UPDATE

_

Upvotes: 6

Views: 2228

Answers (1)

Constantin Galbenu
Constantin Galbenu

Reputation: 17683

If you don't persist the event (i.e. not using Event sourcing) then you can't easily rebuild a read-model. Your Rebuilder must somehow try to reverse engineer the write model and fabricate some events which is weird because the write model could not even contain all the information as it does not need it in order to do his job.

So, my conclusion is that, without an event store or at least an event log then you cannot rebuild your read-model. If you have some source of truth like this then you can rebuild it and even detect the out-of-sync situation by using a list of all processed event IDs in some persistence.

Upvotes: 1

Related Questions