DEV Community

Cover image for Difference Between Message vs Event vs Command
Muhammad Ilham hidayat
Muhammad Ilham hidayat

Posted on • Updated on

Difference Between Message vs Event vs Command

Recently, I'm relearning event-driven architecture and publisher-subscriber systems. I often found words like message, event, and command. Those words can be confusing for someone who want to learn event-driven architecture. Even though they have many common elements, they have different purposes and different properties.


Message is a request from one system to another contain a payload of all data required for processing. It can use a different format based on a contract that exists between two systems. A message has no special intent that makes it generic but also less meaningful. That's why we can use two more concepts on top of the messages.

Alt Text

Message is a generic form for command and event


Command is a message from one system to another for an action to be taken. It represents a possible future and can be validated, approved, rejected, processed, and replied.

Alt Text

Sender send a command to receiver


Alice asked Bob to purchase an iPhone.

The key command is: Buy an iPhone


An event is a message to inform something has already happened in the past. An event represents the past, and it never changes once it's happened. It's immutable, and we can't approve or reject events in the past.

Alt Text

Receiver send an event to notify sender


After receive a command from Alice, Bob go to Apple store and buy a new iPhone. Bob inform Alice he already purchased an iPhone.

The key event is: iPhone already purchased


  • Message is a generic request.
  • Command is a message to perform an action.
  • Event is a message to inform an action has been performed.


Top comments (0)