28

I'm studying domain driven design (DDD) and came across terms: Event Driven and Event sourcing. I know it's about publishing event from producer to consumer, and store the log, so my question is:

What is the difference between Event Driven and Event sourcing?

J.J. Beam
  • 461
  • 1
  • 4
  • 7

1 Answers1

46

The term Event driven architecture is used for any kind of software system which is based on components communicating mainly or exclusively through events. For example, almost any major GUI framework on any popular platform uses event-driven mechanics. The term "event" usually means "notification" in this context.

Event sourcing is a much more special term, referring to systems where the whole application state is stored as a sequence of events. A well-known popular class of examples are transactional database systems, which store any state changes in a transaction log. Here, the term "event" refers more to "state change", not only to "notification".

So any system which uses "event sourcing" as its core mechanics can be seen as also as an even-driven system, but the opposite is not true in general.

Doc Brown
  • 199,015
  • 33
  • 367
  • 565
  • 2
    Upvoted your answer. I'm looking this up now myself, and came across your answer first. Looking at the phrase "the whole application state is stored as a sequence events", it looks like you're saying this: "The application's state is not persisted directly in its current form. Instead, each create, update, or delete operation performed on an object or model is considered an 'event', and it's those 'events' that are directly persisted. So to get the current state of an object, you have to replay those events in order to reconstruct a copy of it." Does this sound correct? – Panzercrisis Feb 26 '20 at 17:41
  • 1
    @Panzercrisis: I should have written "Event Sourcing stores all *changes* to the application state as a sequence of events." (like Fowler). All objects usually have a "current" state, this state may also be persisted (maybe deferred), as well as the event sequence itself. I recommend to read Fowler's article for a full explanation. – Doc Brown Feb 26 '20 at 21:13