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

βœ… Complete vs Next

Every action must tell WJb what should happen after it finishes.

There are two primary outcomes:

  • Complete β€” the workflow ends
  • Next β€” one or more new jobs are scheduled

Complete

Use Complete when the current job is the final step.

No result

return await CompleteAsync();

With a result

return Results.Complete(
    new { Sent = true, MessageId = "abc-123" });

Scalar values are also supported:

return Results.Complete(42);
return Results.Complete("done");
return Results.Complete(true);

The returned value becomes the job result and is stored.


Next

Use Next when the workflow should continue.

Single next step

return await NextAsync<LogAction>(
    new LogInput { Message = "Email sent" });

This creates one new job for LogAction.

Multiple next steps (fan-out)

return Results.Next(
    JobCommands.Next<LogAction>(
        new LogInput { Message = "Email sent" }),
    JobCommands.Next<AuditAction>(
        new AuditInput { Event = "email" }));

Both jobs are enqueued and can run independently.


Side-by-Side

| Intention | Return | Effect | |-------------------------------|---------------------------------|---------------------------------| | Finish the workflow | CompleteAsync() | Job marked Completed | | Finish and save a value | Results.Complete(value) | Job Completed + result stored | | Continue with one action | NextAsync(payload) | One new job created | | Continue with several actions | Results.Next(...) | Multiple new jobs created |


Typical Pattern

public override async Task<IActionResult> ExecuteAsync(
    EmailInput input,
    CancellationToken ct)
{
    // do the work
    await SendEmailAsync(input, ct);

// decide what happens next return await NextAsync<LogAction>( new LogInput { Message = $"Email sent to {input.To}" }); }

Later, in LogAction:

return await CompleteAsync();

Key Point

  • Complete ends the current branch of the workflow.
  • Next creates the continuation.
The action always makes this decision explicitly.

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.