An operation is idempotent when applying the same input repeatedly produces the correct effective outcome. In a CQRS view, an event handler may receive the same event more than once, so its create, update, and delete methods must tolerate duplicate application. section 13.3.3
Choose a response based on the update and the cost of temporary staleness:
- Set a field to a value from the event when repeating that assignment produces the correct outcome. section 13.3.3
- Detect and discard duplicates for non-idempotent updates, such as adding a delivery time to a running sum. One approach records processed event IDs. section 13.3.3
- Consider duplicate detection even for idempotent updates if replaying older events can make the view temporarily stale. section 13.3.3
Duplicate delivery events
An order history view receives DeliveryPickedUp and DeliveryDelivered, then receives both again after the broker redelivers from an earlier point. Processing the second pickup temporarily returns the order to an outdated state; the second delivery restores it. Discarding duplicates avoids that temporary regression. section 13.3.3
Figure 13.9 The DeliveryPickedUp and DeliveryDelivered events are delivered twice, which causes the order state in the view to be temporarily out of date.
The event sequence shows how duplicate processing can temporarily regress an order view. section 13.3.3
Duplicate handling is separate from handling events that arrive out of order. For example, an upsert can create a missing view record or update an existing one when customer and order events arrive in either order. Maintaining a CQRS view also requires replay support and adds development and operational overhead. section 13.3.3 section 13.2.3



















