Real-World Event Sourcing:

@autodidaddict

Real World Event Sourcing: Page 105 of version 3 (PDF)

Inconsistent descriptions around whether Aggregates can process events or only commands.

An aggregate’s internal state can change by replaying events that predate the newly deployed aggregate, but that doesn’t alter the timeline, so it’s allowed.

The book seems to not be internally consistent with if aggregates are meant to process events or only commands.

Sometimes the book says that Aggregates execute commands to produce events (with Process Managers doing the inverse), but then quotes like this trickle through and I get a little confused.

I did look at the Commanded api, and it doesn’t seem to provide a way to process events in aggregates.

Hello. I’m also reading this book. I believe aggregates consume events to build internal state and then use that state to vet commands. It looks like apply/2 serves this purpose. There’s an example here.

I was confused by this paragraph too. The book hasn’t talked about replaying events, and how that might affect the Aggregate. But it seems that:

The aggregate’s apply/2 handles events during both:

  1. emitting an event (after processing a command)
  2. replay (when the aggregate is loaded from the event store)

Aggregates listen to their own events!

BTW, the page number changed to 109 in the _Book version_: P1.0—February 2025