Imagine a small online store. When a customer confirms a purchase, the application needs to save the order and notify other services. A notification service sends a confirmation, while a shipping service begins preparing the delivery.
This scenario illustrates two distinct responsibilities: storing information and communicating that something happened. Dapr provides APIs for both through its state management and publish/subscribe building blocks.
This article explores a conceptual design rather than a tested implementation.
Saving the Order with State Management
Dapr’s state management API lets applications save and retrieve key/value pairs using a configured state store component. In our store, a key such as order-123 could identify an order’s data.
The application calls the Dapr API, while the component configuration specifies the underlying storage system. This separation can reduce application code changes when switching infrastructure.…