Commands and Events

Commands and Events are two of the building blocks of Event Sourcing. In order to reconstruct the state of an entity in memory we must read the history of events for that entity from the datastore and process each event one at a time.

Once the state reconstruction finishes, the entity is ready to process new commands. A command is a request to mutate the state.

Events will be serialized and published into the Journal table in the database. The Journal can then be consumed by the emitting entity or by third parties (e.g. to build an aggregate or other kinds of projections). Events are built on top of messages.

A client trying to mutate the state of an entity will produce a command message and send it to the entity. Commands are a type of message. Sometimes, commands include the address of the sender, the entity can use the sender address to send a message back with a reply.

Events are facts new tab, while commands are requests for a state mutation.