Workflows, brokers, and actors
Workflows and engines
A payment may call fraud, card, and bank services. Together the steps form a workflow; each step is a task. A workflow engine runs the whole thing. Its orchestrator decides when and where each task runs, how many run at once, and what to do on a crash. Its executors run the tasks. Runs start on a timer or from outside, like a web request. Engines exist for data pipelines (ETL), business process diagrams, and durable execution.
Durable execution
You cannot wrap several services in one database transaction. So a crash could debit the card but skip the deposit. Durable execution logs every call and its result. After a crash it runs again, and logged calls return their saved results instead. The workflow as a whole acts exactly once.
Durable execution pitfalls
Replay expects the same calls in the same order. So workflow code must be deterministic: use the framework's time and random helpers, not the system's. Deploy changed code as a new version, so old runs replay with old code. A call made but not yet logged will be made again, so outside services need idempotent APIs and unique IDs.
Message brokers
A sender posts a message to a broker and moves on. The broker buffers messages, redelivers after a crash, and removes the need for service discovery. A queue gives each message to one consumer. A topic gives it to every subscriber. Brokers carry bytes, so teams choose an encoding and often a schema registry. Many brokers delete messages after they are read.
Distributed actors
An actor has private state and talks only by messages, which may be lost. It handles one message at a time, so it needs no locks. Distributed frameworks send these messages between machines, so they act like a message broker and actors in one. Rolling upgrades still need compatible messages.
Remember
- Durable execution logs calls so finished steps are not repeated.
- Replay needs deterministic code and idempotent outside APIs.
- Queue: one consumer. Topic: every subscriber.
- Actors expect lost messages, so remote messaging fits them.