Publishing an Event After a Committed Change

An event can describe a stored change to other components. Its publication contract should say how the event corresponds to the committed data.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a saved article
  2. Make reruns safe
  3. Trace the gap between a write and a separate notification
  4. Give consumers an event identity and revision where appropriate

Trace a saved article

After a title change commits, a search indexer can consume a recorded update event. An event sent before commit could describe a change that later aborts. See state and event intent.

Make reruns safe

If two deliveries describe one saved version, the consumer can verify the event identity and version. Handling repeated events distinguishes delivery from effect.[1]

Trace the gap between a write and a separate notification

If a service commits an article update then crashes before emitting an event, a downstream index may never hear about it. A recorded publish intent in the same transaction gives a worker something durable to deliver later. See saving data and a notification intent.

Commit revision and pending event together
Delivery worker reads pending event
Publish, then record outcome
A crash after publish can require deduplication on retry

Give consumers an event identity and revision where appropriate

Duplicate and late deliveries are possible in many designs. Test a failed attempt and replay through the real consumer. Verify state and completion records independently.

References

  1. Google, Site Reliability Engineering ↩