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
π Fire-and-Forget + Continuation
This pattern lets you start work without waiting for it to finish, while still defining what should happen afterward.
Caller
β
β Enqueue (fire-and-forget)
βΌ
Action A
β
Action B (continuation)
β
Complete
The caller does not block. The workflow continues in the background.
Fire-and-Forget
Simply enqueue a job and continue:
await wjb.EnqueueAsync("process-order",
new OrderInput { OrderId = orderId });
// caller continues immediately
return Results.Accepted();
The HTTP request (or any other caller) returns at once. Processing happens later in a worker.
Adding a Continuation
The first action decides what runs next:
[ActionName("process-order")]
public sealed class ProcessOrderAction : JobAction<OrderInput>
{
public override async Task<IActionResult> ExecuteAsync(
OrderInput input, CancellationToken ct)
{
await ProcessAsync(input, ct);
// continuation
return await NextAsync<SendConfirmationAction>(
new EmailInput
{
To = input.CustomerEmail,
Subject = "Order Processed",
Body = $"Order {input.OrderId} is ready"
});
}
}
After the order is processed, a confirmation email is automatically scheduled.
Full Flow
API / Caller
β
β Enqueue("process-order")
βΌ
process-order β runs in background
β
send-confirmation
β
Complete
When to Use This Pattern
Use Fire-and-Forget + Continuation when:
- The caller should not wait for the work to finish
- You still need reliable follow-up steps (email, audit, cleanup, etc.)
- The work can be executed asynchronously by workers
- Order processing after checkout
- Report generation after a user request
- File import started from an API
- Any long-running operation triggered by a user action
Advantages
- Fast response to the caller
- Reliable background execution
- Explicit continuation (no hidden callbacks)
- Easy to monitor and retry
Key Point
Fire-and-forget starts the work. The action itself defines the continuation.
You get non-blocking behavior without losing control of the workflow.