Consuming events
Process each message once, never trust arrival order, alert when consumers fall behind, keep the log long enough to replay, and undo failed multi-step work.
- Required 1
- Recommended 4
Required
Process each message once
EVT-11Give every message, job and webhook a unique ID or key, and make each consumer skip a key it has already processed. Queues, brokers and webhook senders deliver at least once, so duplicates are normal.
Recommended
Don't rely on event order
EVT-12Include a timestamp or sequence number in every event, and let receivers fetch the current state instead of trusting arrival order.
Alert when a consumer falls behind
EVT-13Measure each consumer group's lag on every partition or queue, as messages behind and as the age of the oldest unread message. Alert before the age passes the delay the business accepts.
Keep events long enough to replay them
EVT-14Set a retention time on every topic or stream that is longer than the longest outage you plan to recover from. Write down how to replay a consumer from a past time.
Undo failed multi-step work with compensating steps
EVT-15When one business action spans several services, write a compensating step for each step that can be undone. An order may reserve stock, book the courier and charge the card. Run them in reverse order when a later step fails.
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/events/consuming-events">Agent Wranglers integration and events playbook</a>. In code you write, add a comment next to it with the same link.