Long Process Pipelines

Long Process Pipelines

Run Anvia pipelines outside the request path with a durable queue.

Use a long process pipeline when the work should not finish inside one HTTP request. The request validates input and creates a job. A worker process runs the Anvia pipeline, persists the result, and reports progress through app-owned status records.

What is BullMQ?

BullMQ is a Node.js queue library built on Redis. A Queue adds jobs, a Worker processes jobs, and QueueEvents can observe queue lifecycle events. BullMQ uses Redis connections so API producers and worker processes can run separately and scale independently.

Install BullMQ in the application that owns the queue and worker:

pnpm add bullmq ioredis

The docs app does not need these dependencies unless it is also running a queue worker.

When to Use It

Use this pattern when:

  • a pipeline can run longer than the caller should wait
  • work should survive API process restarts
  • jobs need retry, backoff, delayed execution, or worker concurrency
  • pipeline results should be persisted for later polling or review
  • API and worker processes scale independently

Architecture Shape

LayerResponsibility
API routeauthorize caller, validate input, create app record, enqueue job
BullMQ queuestore pending jobs, retry policy, backoff, job lifecycle
worker processconsume jobs, run the Anvia pipeline, update progress
pipelineown typed stages, agents, extractors, and deterministic transforms
app storagedurable status, result, errors, audit metadata
observabilityconnect queue job ids, pipeline stage events, traces, and logs

Baseline Flow

Loading diagram...

Keep the API response small. Return a job id and store user-facing status in your own database. BullMQ return values are useful for worker internals and queue inspection, but product status pages should read durable app records.

Pages