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

πŸ“– How to Read a Workflow

A WJb workflow is just a chain of actions connected by results.

Reading it is straightforward once you know where to look.


Step 1 β€” Find the Starting Action

Locate the action that is enqueued first.

await wjb.EnqueueAsync("send-email",
    new EmailInput { To = "user@test.com" });

or

await wjb.EnqueueAsync<SendEmailAction>(...);

This is the entry point of the workflow.


Step 2 β€” Open the Action

Look at the ExecuteAsync method.

public override async Task<IActionResult> ExecuteAsync(
    EmailInput input, CancellationToken ct)
{
    // business logic

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

Two questions matter:

1. What work does this action perform? 2. What does it return?


Step 3 β€” Follow the Result

Complete

return await CompleteAsync();

or

return Results.Complete(someValue);

β†’ The workflow ends here.

Next

return await NextAsync<LogAction>(...);

or

return Results.Next(
    JobCommands.Next<LogAction>(...),
    JobCommands.Next<AuditAction>(...));

β†’ Follow each listed action.


Step 4 β€” Repeat

Open the next action and repeat the same process until you reach Complete.


Full Example

SendEmailAction
      ↓
LogAction
      ↓
Complete
// SendEmailAction
return await NextAsync<LogAction>(
    new LogInput { Message = $"Email sent to {input.To}" });

// LogAction Console.WriteLine(input.Message); return await CompleteAsync();

Reading the two methods is enough to understand the entire workflow.


Multiple Branches

When an action returns several commands:

return Results.Next(
    JobCommands.Next<LogAction>(...),
    JobCommands.Next<AuditAction>(...));

The workflow becomes:

          β”Œβ”€β†’ LogAction
SendEmail
          └─→ AuditAction

Read each branch independently.


Quick Checklist

When you open any action, ask:

  • What does this action do?
  • Does it complete the workflow?
  • Which actions does it schedule next?
  • What data does it pass forward?
If you can answer these questions, you understand the workflow.

Key Point

You never need to look for hidden configuration or middleware.

The workflow is fully described by the code of the actions themselves.

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.