Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EventStore without CQRS

I have seen a lot about EventStores but all articles are coupled with talk about CQRS.

We want to use EventStores to integrate bounded contexts, but want to stick with traditional ORM for reading/writing aggregates, to avoid the command/query and separate read-model which in our case would add too much complexity.

Seeing as it is so popular talking about both concepts together one is led to believe they are meant to live together - are there pitfalls of doing an EventStore 'lite' without CQRS, compared to implementing EventStores for aggregates/CQRS/read-model also?

like image 472
morleyc Avatar asked Mar 27 '13 09:03

morleyc


People also ask

Should I use Repository pattern with CQRS?

If you're applying CQRS and Vertical Slice Architecture you'll likely want a repository to build up Aggregates. However, for a Query, you may want to just get the data you need rather than an entire aggregate (or collection of aggregates) to build a view model.

What is the difference between CQS and CQRS?

CQRS takes the defining principle of CQS and extends it to specific objects within a system, one retrieving data and one modifying data. CQRS is the broader architectural pattern, and CQS is the general principle of behaviour.

What is the difference between CQRS and Event Sourcing?

CQRS is implemented by a separation of responsibilities between commands and queries, and event sourcing is implemented by using the sequence of events to track changes in data.

Is GraphQL a CQRS?

GraphQL makes a strong distinction between input and output object types, which must be defined separately. This makes it perfectly compatible with the CQRS concepts.


2 Answers

Run to NoSql Distilled - you'll save a lot of time by doing nothing for a few days but reading it and drawing out what you're after. If you are 'reading/writing aggregates' you should be considering databases such as RavenDB that major in that.

Note that the event-store tag is for the JOliver Event Store, and it has as key architectural notions

You also have things slightly backwards in that to get to producing events, your domain gets built in a particular manner to facilitate that. Key things that contrast with the way you posit things in your question (to paraphrase badly and/or unfairly: I want to use event store just to store events - I can do the rest myself)

  1. events are batched by aggregate - its real unit of management of events

  2. dispatching to something.

Go investigate queue management solutions if you don't want an event sourced domain model. This is a very legitimate thing to do - just dont pretend Event Store is a generalised event pub sub queue.

Having the Dispatcher Project to Denormalizers that build a Read Model is the easy bit - you can use all sorts of exotic stuff but using a familiar tool like a SQL SB with a straightforward database layer like PetaPoco will do fine.

Have you actually done a spike with CommonDomain and EventStore ? Have you read the readme doc in the nuget? Have you watched the 2 JOliver videos?

  • CQRS - Utah Code Camp 2010 - Part 1 AND 2
  • CQRS - An Introduction for Beginners
  • Jonathan Oliver on Event Sourcing and EventStore @ E-VAN 25 October 2011
like image 99
Ruben Bartelink Avatar answered Sep 28 '22 05:09

Ruben Bartelink


We want to use EventStores to integrate bounded contexts

It is possible to use an event store as a message queue with the added benefit that it is persistent and a new subscriber can request all past events.

but want to stick with traditional ORM for reading/writing aggregates, to avoid the command/query and separate read-model which in our case would add too much complexity.

As an aside, you can still attain some of the benefits of CQRS by simply using a separate read-model for queries rather than your behavioral model.

Overall, you can use an EventStore without using event sourcing, however you should ensure that it supports all requirements of your integration scenario. It may be that you need other components in addition to an event store. More generally, an event store could be used to store any time series data.

like image 25
eulerfx Avatar answered Sep 28 '22 03:09

eulerfx