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
β‘οΈ Multiple Next
An action can schedule more than one next job at the same time.
This creates a fan-out:
βββ LogAction
SendEmail
βββ AuditAction
How to Return Multiple Commands
Use Results.Next and pass several JobCommands:
return Results.Next(
JobCommands.Next<LogAction>(
new LogInput { Message = "Email sent" }),
JobCommands.Next<AuditAction>(
new AuditInput { Event = "email-sent" }));
Both jobs are enqueued independently.
Full Example
[ActionName("send-email")]
public sealed class SendEmailAction : JobAction<EmailInput>
{
public override async Task<IActionResult> ExecuteAsync(
EmailInput input, CancellationToken ct)
{
// send the email...
return Results.Next(
JobCommands.Next<LogAction>(
new LogInput
{
Message = $"Email sent to {input.To}"
}),
JobCommands.Next<AuditAction>(
new AuditInput
{
Event = "email",
Target = input.To
}));
}
}
What Happens at Runtime
1. SendEmailAction finishes successfully.
2. WJb creates two new jobs from the returned commands.
3. Both jobs are stored and become available for workers.
4. The two branches run independently.
SendEmailAction
ββββ LogAction β Complete
ββββ AuditAction β Complete
Order Is Not Guaranteed
The jobs created by multiple next commands do not have a defined execution order.
If order matters, use sequential Next instead of fan-out.
When to Use Fan-out
Use multiple next when the steps are independent:
- Logging + auditing
- Sending notifications to different channels
- Triggering parallel processing of the same data
- Starting several independent follow-up workflows
Key Point
Returning multiple commands is the explicit way to create parallel branches.
Each branch is a normal job and follows the same execution rules as any other job.