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
π€ Fan-out
Fan-out is the pattern where one action starts several independent jobs at the same time.
βββ Action B
Action A ββΌββ Action C
βββ Action D
The branches run independently and do not wait for each other.
How to Create Fan-out
Return multiple commands from a single action:
return Results.Next(
JobCommands.Next<LogAction>(
new LogInput { Message = "Order created" }),
JobCommands.Next<SendEmailAction>(
new EmailInput { To = customer.Email }),
JobCommands.Next<AuditAction>(
new AuditInput { Event = "order-created" }));
Full Example
[ActionName("create-order")]
public sealed class CreateOrderAction : JobAction<OrderInput>
{
public override async Task<IActionResult> ExecuteAsync(
OrderInput input, CancellationToken ct)
{
var order = await CreateOrderAsync(input, ct);
return Results.Next(
JobCommands.Next<SendConfirmationAction>(
new EmailInput
{
To = order.CustomerEmail,
Subject = "Order Confirmation",
Body = $"Order {order.Id} received"
}),
JobCommands.Next<UpdateInventoryAction>(
new InventoryInput
{
ProductId = order.ProductId,
Quantity = order.Quantity
}),
JobCommands.Next<LogAction>(
new LogInput
{
Message = $"Order {order.Id} created"
}));
}
}
Execution Flow
create-order
ββββ SendConfirmationAction β Complete
ββββ UpdateInventoryAction β Complete
ββββ LogAction β Complete
All three jobs are enqueued at the same time and can run in parallel (subject to available workers).
Important Characteristics
- Order of execution between branches is not guaranteed
- Each branch is a normal independent job
- Failure in one branch does not automatically cancel the others
- Data passed to each branch can be different
When to Use Fan-out
Use fan-out when the follow-up steps are independent:
- Sending notifications through multiple channels
- Logging + auditing
- Updating several systems in parallel
- Starting multiple independent processing pipelines
When Not to Use Fan-out
Avoid fan-out when:
- Steps must run in a specific order
- One step needs the result of another
- You need a single final βall doneβ signal (use sequential or a joining pattern instead)
Key Point
Fan-out is created simply by returning multiple JobCommands.
It is the explicit way to start parallel work in WJb.