Managing Service Orchestration
1. Orchestration Pattern
| Aspect | Detail |
|---|---|
| Central Brain | Orchestrator decides next step |
| vs Choreography | Explicit control flow vs emergent |
| Pros | Visibility, easier change, single audit |
| Cons | Single point of complexity if not careful |
2. Process Manager Pattern
| Aspect | Detail |
|---|---|
| Definition | Stateful component managing long-running business process |
| Driven By | Events; emits commands |
| Persists | Workflow state, history, timers |
| Tools | Camunda, Temporal, Conductor |
3. Routing Slip Pattern
| Aspect | Detail |
|---|---|
| Mechanism | Message carries list of steps; each service does its work and forwards |
| Dynamic | Slip can be customized per message |
| No Central Coordinator | State travels with message |
4. Centralized Workflow Pattern
| Aspect | Detail |
|---|---|
| Definition | One workflow engine governs many processes across the org |
| Pros | Reuse engine, common observability, BPM tooling |
| Cons | Becomes shared platform; team contention; vendor lock-in |
5. Workflow State Machine Pattern
| Concept | Detail |
|---|---|
| States | Valid lifecycle stages |
| Transitions | Triggered by events/commands |
| Guards | Conditions to allow transition |
| Actions | Side-effects on entry/exit |
| Persistence | State + version stored per instance |
6. Compensation Workflow Pattern
| Aspect | Detail |
|---|---|
| Definition | Workflow that runs on failure to undo prior steps |
| Order | Reverse of forward steps (LIFO) |
| Tracked | Each forward step records its compensation |
| Re-runnable | Each compensation idempotent |
7. Long-Running Transaction Pattern
| Property | Detail |
|---|---|
| Duration | Hours, days, weeks (e.g., loan approval) |
| State | Persisted; survives restarts |
| Timers | Schedule waits, deadlines, escalations |
| Engines | Temporal, Camunda, Step Functions, Cadence |
Example: Temporal Workflow
@WorkflowInterface
public interface OnboardingWorkflow {
@WorkflowMethod
OnboardingResult run(OnboardingRequest req);
}
public class OnboardingWorkflowImpl implements OnboardingWorkflow {
public OnboardingResult run(OnboardingRequest req) {
identity.verify(req);
Workflow.sleep(Duration.ofDays(2)); // wait for KYC
kyc.runChecks(req);
return account.create(req);
}
}
8. Pipeline Pattern
| Aspect | Detail |
|---|---|
| Definition | Sequence of processing stages; output of stage N → input of N+1 |
| Implementation | Topic per stage, microservice consumer per stage |
| Pros | Independent scaling; clear stage boundaries |
| Examples | Image processing, ETL, video transcoding |
9. Orchestration Engine Pattern
| Capability | Detail |
|---|---|
| Workflow DSL | BPMN, code-as-workflow, JSON DSL |
| State Persistence | Durable storage of running workflows |
| Timers / Signals | Wait for time / external event |
| Visibility | UI for inspection, retry, terminate |
| Worker Model | Workers poll engine for tasks |
10. Process Choreography Pattern
| Aspect | Detail |
|---|---|
| Definition | Decentralized; each service knows its inputs/outputs |
| Coordination | Via events through broker |
| Visibility | Achieved via tracing + event monitoring tools |
| Best For | Domain-aligned events; loose coupling priority |