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.

An unhandled error has occurred. Reload πŸ—™

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.