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

πŸ”„ Full Execution Flow

Every job in WJb follows the same clear path.

Enqueue
 ↓
Store
 ↓
Dequeue
 ↓
Action
 ↓
Result
 ↓
Complete or Next

Nothing is hidden. Every step is explicit.


1. Enqueue

A job is created and placed into the store:

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

The job is now waiting.


2. Store

The store holds:

  • Job payload
  • Status
  • Progress
  • Result
  • Error information
Until a worker is ready, the job simply waits.

3. Dequeue

A worker (or executor) takes the next available job from the store.

Pending β†’ Running

4. Action Execution

The executor:

1. Creates the action 2. Converts the payload into the action input 3. Calls ExecuteAsync

public override async Task<IActionResult> ExecuteAsync(
    EmailInput input, CancellationToken ct)
{
    // business logic here
    return await CompleteAsync();
}

5. Result Processing

The action returns an IActionResult.

Complete

return await CompleteAsync();
// or
return Results.Complete(someValue);

The job is marked as completed. Any returned value is stored as the job result.

Next

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

New jobs are created from the returned commands and placed back into the store.

Failure

throw new InvalidOperationException("Something went wrong");

The job is marked as failed. Error details are stored.


6. Loop

After the current job finishes, the worker can immediately take the next one:

Dequeue β†’ Execute β†’ Complete/Next β†’ Dequeue β†’ ...

This continues until no more jobs are available or the worker is stopped.


Full Picture

Enqueue
   ↓
Store (Pending)
   ↓
Dequeue
   ↓
Action.ExecuteAsync
   ↓
IActionResult
   β”œβ”€β”€ Complete  β†’ Job Completed
   β”œβ”€β”€ Next      β†’ New Jobs Enqueued
   └── Exception β†’ Job Failed

Key Point

The executor never decides the workflow.

The action decides what happens next by returning a result.

That is the full execution flow of WJb.

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.