Podstawy Event Sourcingu

Większość systemów trzyma tylko bieżący stan i nadpisuje go przy każdej zmianie. Event Sourcing zapisuje każdą zmianę biznesową jako zdarzenie i z tych zdarzeń odtwarza stan. Masz pełną historię tego, co się wydarzyło, a kod bliżej odzwierciedla proces biznesowy. Sam pomysł jest prosty. Trudniej ocenić, gdzie się opłaca, i zacząć tak, żeby się nie sparzyć.

Pierwsze artykuły pokazują, jak to działa, razem z ćwiczeniami do samodzielnego zrobienia. Kolejne pomagają podjąć decyzję: co zyskujesz, nie tracąc danych, kiedy Event Sourcing się nie opłaca i jak wybrać pierwszą funkcjonalność, na której czegoś się nauczysz bez dużego ryzyka. Ostatnie odpowiadają na pytania o modelowanie, które pojawiają się szybko, np. jak przenieść istniejące dane relacyjne na zdarzenia.

Jeśli dopiero zaczynasz, czytaj po kolei. Przechowywaniu zdarzeń poświęcony jest osobny przewodnik.

  1. Introduction to Event Sourcing - Self Paced Kit

    2022-03-16For many developers, Event Sourcing is like a Nessie, most of them have heard of it, but not many have seen it. I was one of them. I started my journey with Event…
  2. How to get the current entity state from events?

    2021-06-30Today I’d like to go back a bit to the basics of Event Sourcing. I recently realised that I often cover more advanced topics. So sometimes, it’s handy to take a step back…
  3. Should you throw an exception when rebuilding the state from events?

    2022-06-08Event Sourcing is not a difficult pattern to understand. Event stores are not conceptually complicated databases (although implementation may be quite complex). We have…
  4. Event Sourcing on PostgreSQL in Node.js just became possible with Emmett

    2024-07-12Last week, I announced Pongo - Mongo, but it was on PostgreSQL. So, the Node.js library allows using PostgreSQL as a document database. Today, I have at least an equally…
  5. Why a bank account is not the best example of Event Sourcing?

    2020-12-09While explaining the Event Sourcing, bank account balance calculation is a common starting point. I claim that even though it sounds right, then it’s not the best example…
  6. Never Lose Data Again - Event Sourcing to the Rescue!

    2022-11-06Relational databases are not losing data. They’re robust, consistent and secure! Are they? Too often, we mix technical and logical concepts. Business transactions are not…
  7. Start Small, Grow Big: how to pick the first feature for Event Sourcing

    2026-08-31Let’s say we did the hard part. We read up on Event Sourcing, even here on my blog; we did a modelling workshop, we got the nods around the table, and someone finally…
  8. When not to use Event Sourcing?

    2021-06-23Event Sourcing is perceived as a complex pattern that’s challenging to learn. Typically it’s matched with the financial industry or big enterprise systems. If you’re…
  9. Is the audit log a proper architecture driver for Event Sourcing?

    2023-05-20Usually, one of the main drivers for Event Sourcing is the audit log capability. Indeed event stores are append-only logs, theoretically, we’re getting that for free. Yet…
  10. Hitchhiker's Guide To Moving From Relational Data To Events

    2023-12-15Knock knock? Who’s there? It’s me, Oskar, the end is near, did you know that? Ah, you know it but don’t know how to proceed? Let’s talk about the end of the CRUD world…
  11. Should you record multiple events from business logic?

    2024-01-14Asking people for feedback is an intriguing story. I like to get constructive criticism for my work, as that allows me to learn something new. When I prepare some new…
  12. Stream ids, event types prefixes and other event data you might not want to slice off

    2024-01-21You’re reading much more code than you’re writing. Readability is a highly subjective term. That’s probably why some call what we’re doing craft or even art. Last week…
  13. What's the difference between a command and an event?

    2021-02-17What’s the difference between a command and an event? The answer seems apparent, but let’s see if it’s straightforward. The command represents the intention. It targets a…