Messaging
A Broker Becomes the Intermediary Between Services
With messaging, the sender does not call a specific receiver instance directly. It publishes a message to a broker, and a receiver retrieves and processes it separately.
Producer -> Broker -> Consumer
|
+-> stores messages temporarily
The broker helps break the direct dependency on participant addresses and availability: the producer does not have to know which exact instance will process the message right now.
A Message Should Be a Standalone Contract
The receiver needs enough data for processing and a stable format. If a message contains only internal details of the sender, changes to its implementation will begin breaking consumers.
{
"eventId": "8b7b...",
"orderId": 421,
"type": "ORDER_CREATED"
}
A Queue Smooths Out Speed Differences
If a producer temporarily creates messages faster than a consumer can process them, the broker can hold the accumulated work. Consumers then process it at their own pace.
But the queue itself becomes an important part of the system: backlog size, processing errors, and messages that still fail after retries all need to be monitored.