WJb Docs - Intermediate
Learn workflows, persistence, scheduling, and production-ready patterns.
π Start Here
π§© Mental Model
π Building Workflows
π₯ Failures & Control
π Observation & Debugging
π Practical Patterns
β Working Examples
β‘οΈ Whatβs Next
π Sequential Workflow
A sequential workflow is the simplest and most common pattern in WJb.
Each action runs one after another in a clear chain.
Action A
β
Action B
β
Action C
β
Complete
How to Build It
Each action returns Next pointing to the following action.
The last action returns Complete.
Example: Import β Process β Notify
[ActionName("import")]
public sealed class ImportAction : JobAction<ImportInput>
{
public override async Task<IActionResult> ExecuteAsync(
ImportInput input, CancellationToken ct)
{
var data = await ImportDataAsync(input, ct);
return await NextAsync<ProcessAction>(
new ProcessInput { Data = data });
}
}
[ActionName("process")]
public sealed class ProcessAction : JobAction<ProcessInput>
{
public override async Task<IActionResult> ExecuteAsync(
ProcessInput input, CancellationToken ct)
{
var result = await ProcessDataAsync(input.Data, ct);
return await NextAsync<NotifyAction>(
new NotifyInput { Result = result });
}
}
[ActionName("notify")]
public sealed class NotifyAction : JobAction<NotifyInput>
{
public override async Task<IActionResult> ExecuteAsync(
NotifyInput input, CancellationToken ct)
{
await SendNotificationAsync(input.Result, ct);
return await CompleteAsync();
}
}
Starting the Workflow
await wjb.EnqueueAsync("import",
new ImportInput { Source = "customers.csv" });
Execution Flow
import
β
process
β
notify
β
Complete
Each step waits for the previous one to finish successfully before it starts.
Passing Data
Data flows forward through the payload of each Next call.
Only the information needed by the next step should be passed.
When to Use Sequential Workflow
Use this pattern when:
- Steps must run in a strict order
- Each step depends on the result of the previous one
- The workflow is linear and easy to reason about
Key Point
A sequential workflow is just a chain of actions where each one explicitly points to the next.
No extra infrastructure or orchestration is required β only clear Next and Complete returns.