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

🌊 Sequential Workflow

A sequential workflow is the simplest and most common pattern in WJb.

Each action runs one after another in a clear chain.

Action A
   ↓
Action B
   ↓
Action C
   ↓
Complete

How to Build It

Each action returns Next pointing to the following action. The last action returns Complete.

Example: Import β†’ Process β†’ Notify

[ActionName("import")]
public sealed class ImportAction : JobAction<ImportInput>
{
    public override async Task<IActionResult> ExecuteAsync(
        ImportInput input, CancellationToken ct)
    {
        var data = await ImportDataAsync(input, ct);

return await NextAsync<ProcessAction>( new ProcessInput { Data = data }); } }

[ActionName("process")] public sealed class ProcessAction : JobAction<ProcessInput> { public override async Task<IActionResult> ExecuteAsync( ProcessInput input, CancellationToken ct) { var result = await ProcessDataAsync(input.Data, ct);

return await NextAsync<NotifyAction>( new NotifyInput { Result = result }); } }

[ActionName("notify")] public sealed class NotifyAction : JobAction<NotifyInput> { public override async Task<IActionResult> ExecuteAsync( NotifyInput input, CancellationToken ct) { await SendNotificationAsync(input.Result, ct);

return await CompleteAsync(); } }


Starting the Workflow

await wjb.EnqueueAsync("import",
    new ImportInput { Source = "customers.csv" });

Execution Flow

import
  ↓
process
  ↓
notify
  ↓
Complete

Each step waits for the previous one to finish successfully before it starts.


Passing Data

Data flows forward through the payload of each Next call.

Only the information needed by the next step should be passed.


When to Use Sequential Workflow

Use this pattern when:

  • Steps must run in a strict order
  • Each step depends on the result of the previous one
  • The workflow is linear and easy to reason about

Key Point

A sequential workflow is just a chain of actions where each one explicitly points to the next.

No extra infrastructure or orchestration is required β€” only clear Next and Complete returns.

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.