Hi,
I’m currently experimenting with event store (described: here), and I’m trying to make some use of projections that do not emit any events, but just produce state to be read from. As I understand, projections really shine when one needs to correlate data in a way that’s not feasible in, say, SQL, and when someone needs querying SQL-like, one should integrate event-store with external storage.
Such integration should be fairly trivial (especially with new subscription API that allows to get events from specific point, that way our app that is maintaining this integration can easily detect how to be up-to-date), but it seems it’s not that easy to mix both: Event Store state projections (which allow to make get-by-id read models dead easy) and externally stored projections (which allow more sophisticated querying).
Back to my example:
I’ve made IssueReadModel projection, which just goes over all events and build read model that looks like:
{
Reporter: “someone”,
ReportedOn: 2012-12-11
Status: “active”,
TakenBy: “someone else”,
TakenOn: 2012-12-12
}
``
Now, I can fetch it from Event Store by id - simple.
Say I want to display list of issues reported by some user - I wouldn’t maintain such list in Event Store, because I’d have to create many such lists for different types of queries, so I dump them in external storage:
-
listen to all issues events
-
project the events (similar manner to what Event Store is doing), and store in, let’s say: SQL table row (with all SQL query benefits)
-
later on, when other event arrives, I could remember last event number (checkpoint), and use it to recreate read model and apply only new event (again, this is what Event Store is doing also I assume (checkpointing))
It seems easy, but here, I do not even touch the Event Store projections, I’m doing everything on my own! I thought I could reuse IssueReadModel projection, but this would just complicate things:
-
listen to issues events
-
when event arrives, use IssueReadModel projection state and store it in your external storage
Now, point 2. cannot be sure that Event Store’ projection state is up to date, so I could either think of something here, or just get back to previous approach…
Am I on the right track that projections really shine when one needs non-SQL-like (from lack of better word) abilities, and when one needs traditional querying than it’s of almost no use?