eventscommandcqrsevent-driven-design

Why are commands and events separately represented?


What is the difference between commands and events in architectures that emphasize events? The only distinction I can see is that commands are usually sourced/invoked by actors outside the system, whereas events seem to be sourced by handlers and other code in a system. However, in many example applications I have seen, they have different (but functionally similar) interfaces.


Solution

  • Commands can be rejected.

    Events have happened.

    This is probably the most important reason. In an event-driven architecture, there can be no question that an event raised represents something that has happened.

    Now, because Commands are something we want to happen, and Events are something that has happened, we should be using different verbs when we name these things. This drives separate representations.

    I can see is that commands are usually sourced/invoked by actors outside the system, whereas events seem to be sourced by handlers and other code in a system

    This is another reason they are represented separately. Conceptual clarity.

    Commands and Events are both Messages. But they are in fact separate concepts, and concepts should be modeled explicitly.