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
Typical cases:

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

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.