0

I am trying to understand the difference between an event log and event store in the context of event sourcing.

A really nice explanation I found is that an event store is the single source of truth for the write model and an event log is the single source of truth for the read model.

Therefore say I wanted to use CQRS without Event Sourcing, then the way I understand it is that I would have an event log write model (Domain Objects serialised to an SQL database) and a NoSQL (MongoDB) read model. The two databases could be in separate API projects communicating using a RabbitMQ.

On that basis it is not a bad idea to use an EventLog when using CQRS without Event Sourcing i.e. when the business is not interested in replaying historic events (in my case the system only has one event).

Is it acceptable for the EventLog to be the write database? i.e. it would contain serialized domain objects.

Have I understood this correctly?

  • that sounds like a bad explanation. do you have a reference? – Ewan Feb 1 at 14:06
  • @Ewan, could you elaborate? I have just done some searching and found the quote on one of my previous questions. The answerer says: "yes, can be a SQL table but the important thing to notice is that it is not the source of truth for the write model but for the read model only. (otherwise it would be an Event store)": chat.stackoverflow.com/rooms/180191/… – w0051977 Feb 1 at 15:01
  • basically what constantin said. Who wrote the "nice explaination" and can we read the full text. – Ewan Feb 1 at 16:05
2

I can't find any authoritative answer between the difference between the two terms: "event log" and "event store". Martin Fowler uses both terms in this post but it's not clear if there is a difference. I think one cannot compare them, they are somewhat orthogonal or from different domains. An Event store is an Event log, that is, a log/list of all events that happened, ordered by the time they occurred.

An Event store is an event persistence that should have the following characteristics:

  • it contains a list of events
  • the events are logically grouped into streams
  • the events in a stream are appended in the order they occurred
  • it can detect/prevent concurrent appending of events on the same stream
  • it is optimised for loading of events on a given stream, in the order they occurred and from a specific point-in-time/stream-version

An Event log is just a list of events that could have the following characteristics:

  • the events could be totally ordered
  • it could fetch all events in the order they occurred and from a specific point in time

So, one could have an event persistence that is an Event store and an Event log, at the same time, at the cost of scalability, of course.

We can notice that an Event log is something that is needed more by the ReadModels because it's easier to design a ReadModel that processes the events in the order they occurred, across all streams.

A really nice explanation I found is that an event store is the single source of truth for the write model and an event log is the single source of truth for the read model.

The "source of truth" is the entity that owns the data, that can guarantee the correctness of the data. For example, the source of truth for the number of items in stock showed on the UI of an online store is the physical warehouse, not it's Event store/database. You cannot say that a something is a source of truth for some consumer; it is or it is not a source of truth, a producer of some truth; it's irrelevant who consumes the truth when deciding that some source is the source of truth.

  • Is it fair to say that if you are using CQRS without event sourcing then the write side event log could be the single source of truth for the read model? – w0051977 Feb 1 at 15:15
  • @w0051977 you didn't understand my answer. You cannot say that some source (i.e. an Event log) is the source of truth for some consumer. It is or it is not a source of truth. Does the Event log own the data in those events? Or the events are a interpretation of something that happened in a remote system? You could say that an Event log is a source (without "of truth") of events that are consumed by ReadModels. The ReadModels can consume events from Event stores as well. – Constantin Galbenu Feb 1 at 15:28
  • The domain model model is serialized to the event log in one web api (write.api). Then another api (read.api) listens for RabbitMQ integration events and the read database is updated. There is only one event. Please note this is a hobby project I am developing for learning purposes in my spare time. – w0051977 Feb 1 at 15:38
  • I think I see what you mean. I believe you are saying that it is the source of truth for everything or nothing. +1. Is it normal for an event log on the write side to be the source of truth? This is the only database on the write side. – w0051977 Feb 5 at 21:19
  • 1
    @w0051977 see here more (I don't use Axon but it's the same idea): axoniq.io/blog-overview/introducing-subscription-queries – Constantin Galbenu Feb 6 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.