Orchestration
It is common that some business processes are implemented as multiple microservice calls. And the implementation must guarantee that all of the calls must eventually succeed even with the occurrence of prolonged downstream service failures. In some cases, instead of trying to complete the process by retrying for a long time, compensation rollback logic should be executed. Saga Pattern is one way to standardize on compensation APIs.
Cadence is a perfect fit for such scenarios. It guarantees that workflow code eventually completes, has built-in support for unlimited exponential activity retries and simplifies coding of the compensation logic. It also gives full visibility into the state of each workflow, in contrast to an orchestration based on queues where getting a current status of each individual request is practically impossible.
Samples
Runnable orchestration samples:
| Sample | Description | Code |
|---|---|---|
| Trip booking Saga | Books a car, hotel, and flight, running compensations when a step fails | Java |
| Saga basics | Minimal example of registering compensations with the Saga class | Java |
| Sequential microservice calls | Chains activities, passing each result to the next step | Go |
| Human-approval orchestration | Expense report workflow that waits on an external approval service | Go |
Following are some real-world examples of Cadence-based service orchestration scenarios: