Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 775
alphadogg Avatar asked Feb 10 '11 21:02

alphadogg


People also ask

What is difference between command and event?

Both are messages. They convey specific information; a command about the intent to do something, or an event about the fact that happened.

What are command events?

Command events are notifications that an MQSC, or PCF command has run successfully. comprises the queue manager from where the command was issued, the ID of the user that issued the command, and how the command was issued, for example by a console command.


1 Answers

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.

like image 185
quentin-starin Avatar answered Nov 16 '22 11:11

quentin-starin