Messages, Events, and Commands

Learn about events, event sourcing, event journal, and messages.


In What Do You Mean by “Event-Driven”? 9^{9} Martin Fowler points out the unfortunate overloading of the word “event.” He and his colleagues identified three main ways events are used, plus a fourth term that is often conflated with events:

  • Event notification: A fire-and-forget, one-way announcement. No response is expected or used

  • Event-carried state transfer: An event that replicates entities or parts of entities so other systems can do their work

  • Event sourcing: When all changes are recorded as events that describe the change

  • Command-query responsibility segregation (CQRS): Reading and writing with different structures. Not the same as events, but events are often found on the “command” side

Event sourcing

Event sourcing has gained support thanks to Apache Kafka 10^{10}which is a persistent event bus. It blends the character of a message queue with that of a distributed log. Events stay in the log forever, or at least until you run out of space. With event sourcing, the events themselves become the authoritative record. But since it can be slow to walk through every event in history to figure out the value of attribute A on entity E, we often keep views to make it fast to answer that question. See the following figure for illustration.

Get hands-on with 1200+ tech skills courses.