Event-Driven Architecture vs Message-Driven Architecture: Four Differences
When designing asynchronous / decoupled / loosely-coupled systems, many of us conflate Event-Driven Architecture with Message-Driven Architecture.
events != messages
Here are four ways to think about the differences between an Event-Driven Architecture [EDA] and a Message-Driven Architecture [MDA]:
1️⃣ EDA is Noun-Oriented. MDA is Verb-Oriented.
• EDA: Notification [Noun] that something happened. E.g., User Visited, Product Added to Cart, Order Placed. Producer is Broadcaster: Consumer chooses what to do with notification, if anything.
• MDA: Instruction [Verb] to do something. E.g., Update Inventory, Ship Order, Email Customer. Producer is Director: Consumer must follow instruction.
2️⃣ EDA is Many Consumers. MDA is Single Consumer.
• EDA: Many consumers can act on any given event / notification.
• MDA: One and only one consumer acts on any given message.
3️⃣ EDA is Dumb-Service-to-Smart Service. MDA is Smart-Service-to-Dumb-Service.
• Dumb Service: Zero to minimal business logic. E.g., Log an event [e.g., "User Visited"] without any further processing; Publish an event [e.g., "Order Placed"] to a stream without any knowledge of who will consume it.
• Smart Service: Intelligent business logic. E.g., Receive a message "Update Inventory" and perform the necessary inventory update logic; Consume a message "Email Customer" and use customer information and order details to craft and send a personalized email.
4️⃣ EDA publishes to Stream / Topic. MDA publishes to Queue.
I'll also add that you can use an event-driven system to implement a message-driven system; but generally not the other way around.
So on AWS, for instance, you can implement an event-driven architecture using:
• Amazon Managed Streaming for Apache Kafka [MSK]
• Amazon Kinesis Data Streams
• Amazon EventBridge
• Amazon Simple Notification Service [SNS]
For a message-driven architecture, I could use any of the above services. Overkill, yes, but possible.
You can implement a message-driven architecture on AWS with Amazon Simple Queue Service [SQS].
However, implementing an event-driven architecture on SQS [or attempting to do so] would be an anti-pattern.
Hope this helps!