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
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.