Event Processing & Actors
This guide covers two complementary patterns. Event-driven workflows react to things that happen — orders placed, payments received, sensors reporting — by executing durable task chains. Actors maintain per-entity state — shopping carts, counters, device twins — with single-writer guarantees. Both are backed by PostgreSQL: every event processed and every state change is journaled.
An event becomes a durable reaction
A plain event handler is fire-and-forget: if the process dies partway through reacting, the half-done work is gone and the event is often lost with it. When the reaction is a workflow, the event is durable — the chain resumes at the step it reached, and the event is acknowledged only once its handler is safely journaled.
Crash mid-reaction loses the in-flight work — and often the event. At-least-once delivery means the retry re-runs everything, duplicates included.
Crash resumes at the reached step; completed steps replay from the journal. Delivery is at-least-once; completed steps are never repeated.
One writer per entity
The hardest part of stateful event processing is concurrency: two events for the same cart arriving at once can interleave and corrupt the state. Actors remove the problem by construction — all operations for one entity are serialized through a single writer, so each operation sees the previous one's committed result. No locks, no lost updates.
The two patterns compose: an actor operation can start a child workflow, and an event-driven workflow can invoke actor operations.
Patterns
Order Processing
React to domain events — orders created, payments received, cancellations — with durable task chains.
Stateful Actors
Maintain per-entity state with single-writer guarantees and event sourcing.
Stream Aggregation
Aggregate high-volume event streams over time windows with durable timers.
Pattern Detection
Correlate multiple events over time for fraud detection, abandoned carts, and SLA monitoring.
Best Practices
Design guidelines, performance characteristics, and next steps.