Event-Carried State Transfer
Include all relevant state data in the event so consumers don't need to call back to the source.
Intent & Description
⚠️ Problem
How can consumers be fully decoupled from the producer without needing to call back for additional data?
📋 Context
Services consume events from other services. With Event Notification, consumers must call back to the source to get full data, which increases coupling, latency, and load on the source service.
💡 Solution
Include all the data that consumers need directly in the event payload. When an event is published, it carries the full state (or a relevant subset) that consumers require for their processing. Consumers maintain their own local copy of the data by processing these events, eliminating the need for synchronous callbacks. This is essentially building a local read-only replica of the source data through events.
Real-world Use Case
Source
Advantages
- Consumers do not need to call back to the source, improving availability and reducing latency
- Consumers maintain local copies of the data they need, enabling autonomous operation
- Reduces load on the source service from callback requests
- Enables consumers to work even when the source service is unavailable
Disadvantages
- Larger event payloads increase bandwidth and storage requirements
- Events become a public API that must be versioned carefully
- Data in consumer replicas is eventually consistent with the source
- More data in events increases coupling between producer and consumer schemas