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

πŸ“€ Fan-out

Fan-out is the pattern where one action starts several independent jobs at the same time.

          β”Œβ”€β†’ Action B
Action A ─┼─→ Action C
          └─→ Action D

The branches run independently and do not wait for each other.


How to Create Fan-out

Return multiple commands from a single action:

return Results.Next(
    JobCommands.Next<LogAction>(
        new LogInput { Message = "Order created" }),
    JobCommands.Next<SendEmailAction>(
        new EmailInput { To = customer.Email }),
    JobCommands.Next<AuditAction>(
        new AuditInput { Event = "order-created" }));

Full Example

[ActionName("create-order")]
public sealed class CreateOrderAction : JobAction<OrderInput>
{
    public override async Task<IActionResult> ExecuteAsync(
        OrderInput input, CancellationToken ct)
    {
        var order = await CreateOrderAsync(input, ct);

return Results.Next( JobCommands.Next<SendConfirmationAction>( new EmailInput { To = order.CustomerEmail, Subject = "Order Confirmation", Body = $"Order {order.Id} received" }), JobCommands.Next<UpdateInventoryAction>( new InventoryInput { ProductId = order.ProductId, Quantity = order.Quantity }), JobCommands.Next<LogAction>( new LogInput { Message = $"Order {order.Id} created" })); } }


Execution Flow

create-order
     β”œβ”€β”€β†’ SendConfirmationAction β†’ Complete
     β”œβ”€β”€β†’ UpdateInventoryAction  β†’ Complete
     └──→ LogAction              β†’ Complete

All three jobs are enqueued at the same time and can run in parallel (subject to available workers).


Important Characteristics

  • Order of execution between branches is not guaranteed
  • Each branch is a normal independent job
  • Failure in one branch does not automatically cancel the others
  • Data passed to each branch can be different

When to Use Fan-out

Use fan-out when the follow-up steps are independent:

  • Sending notifications through multiple channels
  • Logging + auditing
  • Updating several systems in parallel
  • Starting multiple independent processing pipelines

When Not to Use Fan-out

Avoid fan-out when:

  • Steps must run in a specific order
  • One step needs the result of another
  • You need a single final β€œall done” signal (use sequential or a joining pattern instead)

Key Point

Fan-out is created simply by returning multiple JobCommands.

It is the explicit way to start parallel work in 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.