Skip to content

Latest commit

 

History

History
247 lines (172 loc) · 10.4 KB

patterns.md

File metadata and controls

247 lines (172 loc) · 10.4 KB

Orchestration Patterns

This guide maps each common orchestration pattern to available samples and documentation. All patterns can be developed locally using the Durable Task Scheduler emulator.

The JavaScript/TypeScript SDK is available in preview, with JavaScript examples linked below. Go samples in this repository are coming soon; the Go SDK repository contains the beta SDK and its own samples.

A blank table cell means no sample is linked here.


Function Chaining

Sequential execution of activities where the output of one becomes the input of the next.

Activity A → Activity B → Activity C → Result

Use cases: Data processing pipelines, multi-step approval workflows, document generation

Language Durable Task SDK Durable Functions
.NET Sample HelloCities
Python Sample Hello Cities
Java Sample HelloCities
JavaScript Sample HelloCities
TypeScript See the JavaScript SDK sample above HelloCities

📖 Learn more on Microsoft Learn →


Fan-out/Fan-in

Execute multiple activities in parallel and aggregate results when all complete.

         ┌→ Activity A ─┐
Input ───┼→ Activity B ──┼→ Aggregate → Result
         └→ Activity C ─┘

Use cases: Batch processing, parallel API calls, map-reduce operations

Language Durable Task SDK Durable Functions
.NET Sample Large Payload Fan-out/Fan-in
Python Sample Fan-out/Fan-in
Java Sample HelloCities
JavaScript Sample HelloCities
TypeScript See the JavaScript SDK sample above HelloCities

📖 Learn more on Microsoft Learn →


Async HTTP API

Start a long-running operation via HTTP and poll for results.

Client → POST /start → 202 Accepted (with status URL)
Client → GET /status  → 200 Running...
Client → GET /status  → 200 Completed (with result)

Use cases: Long-running API operations, background job processing

Language Durable Task SDK Durable Functions
.NET ASP.NET Web App HelloCities
Python Sample
Java Sample

📖 Learn more on Microsoft Learn →


Human Interaction

Pause an orchestration to wait for external input (approval, user decision) with timeout support.

Orchestration → Wait for approval event
                  ├→ Approved → Continue
                  └→ Timeout  → Escalate/Cancel

Use cases: Approval workflows, manual review steps, interactive processes

Language Durable Task SDK Durable Functions
.NET Sample
Python Sample
Java Sample

📖 Learn more on Microsoft Learn →


Monitoring

Periodic polling pattern that checks status at intervals until a condition is met.

Check status → Not ready → Wait → Check status → Ready → Done

Use cases: Health checks, deployment monitoring, SLA enforcement

Language Durable Task SDK Durable Functions
.NET Sample
Python Sample
Java Sample

📖 Learn more on Microsoft Learn →


Sub-orchestrations

Compose complex workflows by calling child orchestrations from a parent.

Parent Orchestration
  ├→ Sub-orchestration A → Result A
  └→ Sub-orchestration B → Result B

Use cases: Modular workflow design, code reuse, scoped retry logic

Language Durable Task SDK Durable Functions
.NET Sample
Python Sample
Java Sample

📖 Learn more on Microsoft Learn →


Eternal Orchestrations

Long-running orchestrations that use continue_as_new to prevent unbounded history growth.

Process batch → Continue as new → Process batch → Continue as new → ...

Use cases: Event processors, scheduled jobs, continuous monitoring

Language Durable Task SDK Durable Functions
.NET Sample
Python Sample
Java Sample

📖 Learn more on Microsoft Learn →


Bounded Coordinator

A coordinator that fans out child work in bounded batches, waits for all children, then resets history via continue_as_new after each batch.

Coordinator (batch N) → fan out children → wait all → continue_as_new → batch N+1

Use cases: Continuous queue draining, long-running ingestion/ETL pipelines, message-pump coordinators that must avoid history bloat

Language Durable Task SDK Durable Functions
.NET Sample
Python Sample

📖 Learn more on Microsoft Learn →


Durable Entities

Stateful objects that persist their state and support operations via messages.

Entity: Counter
  ├→ Add(5)  → State: 5
  ├→ Add(3)  → State: 8
  └→ Get()   → Returns: 8

Use cases: Shopping carts, user sessions, aggregations, IoT device state

Language Durable Task SDK Durable Functions
.NET Sample
Python Sample
Java Sample Entities

📖 Learn more on Microsoft Learn →


Saga / Compensation

Execute a sequence of operations with compensating actions if any step fails.

Step 1 → Step 2 → Step 3 (fails!)
                    └→ Compensate Step 2 → Compensate Step 1

Use cases: Distributed transactions, order processing, booking systems

Language Durable Task SDK Durable Functions
.NET Saga Sample
Python Sample

📖 Learn more on Microsoft Learn →


Orchestration Versioning

Safely evolve orchestration logic without breaking in-flight instances.

Language Durable Task SDK Durable Functions
.NET Sample
Python Sample

📖 Learn more on Microsoft Learn →


Scheduled Tasks

Run a target orchestration on a recurring interval, with pause/resume and runtime management.

Schedule (every 5s) → Start orchestration → ... → Start orchestration

Use cases: Periodic background jobs, cache clearing, report generation, cron-like recurring workflows

Language Durable Task SDK Durable Functions
.NET Schedule Web App
Python Sample

Next Steps