CQRS,ES: How to know if we have to reorder/ignore

2019-07-22 16:59发布

问题:

Me and my team currently work on the read side of a CQRS and event-sourcing system. We want our projectors to be able to listen to only a subset of all events and we want our projectors to be idempotent since an event can be published many times. Here is our current architecture:

Since a projectionist doesn't handle all events how it can know if an event hasn't been received in the correct order or if an event has already been received? We can't use the sequence number because the sequence number is related to a stream and not an event type.

The terms "projectionist", "projection ledger" and "projector" comes from this article.

回答1:

How to know if we have to reorder/ignore events on read side?

The "Bus" is not the authority for order of events - that responsibility lies with the event store. So a projectionist that needs to know what order things happen should query the store, rather than trying to reconstruct the original ordering from the information on the bus.

Greg Young's 2014 talk Polyglot Data includes a good discussion of this point.

(The projectionist might query the event store via some API, rather than talking to the store directly - a curated atom feed based on the data in the store).