Event sourcing

Event sourcing is a pattern for storing data as events in an append-only log.

Here are important terms about event sourcing:

Command: A command is an action by a user or a system. Commands are usually stored in FIFO queue.

Event: An event can be defined as a change in state. The result of a command is an event. Event is represented as a past tense. Order of event must follow order of command. So, we store events in FIFO queue. Example of events are: order placed, books purchased, etc.

State: State is a change after an event is completed.

State machine: State machine drives the event process. It validates commands and apply events to update the state.

CQRS (Command Query Responsibility Segregation): It is the segregation of commands and queries for a system. As per CQRS, there is one (single) state machine for the write operations. And, there could be multiple state machines for read-only operations.

References:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s