Building Event-Driven Workflows
Coordinate services through events and idempotency.
Event-Driven Workflows
A single message is easy. A workflow — "order placed → reserve stock → charge card → ship → notify" spanning several services — is where event-driven design earns its keep, and where it bites you if done naively.
This lesson covers choreography vs orchestration, the outbox pattern for atomic publishing, sagas for distributed rollback, and the idempotency that holds it all together.
Choreography vs Orchestration
Two ways to coordinate multi-step flows:
- Choreography — each service reacts to events and emits its own; no central brain. Loosely coupled but the overall flow is implicit and hard to trace.
- Orchestration — a central coordinator tells each service what to do next. Explicit and observable, but the orchestrator is a coupling point.
Rule of thumb: choreography for simple fan-out, orchestration when a flow has many ordered steps and needs visible state.
All lessons in this course
- Why Asynchronous Messaging
- Working with RabbitMQ in PHP
- Apache Kafka with PHP
- Building Event-Driven Workflows