bunqueue v2.8 API referenceall versions · guide
bunqueue
    Preparing search index...

    Class FlowProducer

    FlowProducer creates job flows with automatic dependencies.

    const flow = new FlowProducer();

    // Simple chain: A → B → C
    const { jobIds } = await flow.addChain([
    { name: 'fetch', queueName: 'pipeline', data: { url: '...' } },
    { name: 'process', queueName: 'pipeline', data: {} },
    { name: 'store', queueName: 'pipeline', data: {} },
    ]);

    // Parallel then merge
    const result = await flow.addBulkThen(
    [
    { name: 'task1', queueName: 'parallel', data: { id: 1 } },
    { name: 'task2', queueName: 'parallel', data: { id: 2 } },
    ],
    { name: 'merge', queueName: 'final', data: {} }
    );

    Hierarchy

    • EventEmitter
      • FlowProducer
    Index
    closing: Promise<void> = ...
    • Add parallel jobs that converge to a final job.

      Type Parameters

      • T = unknown

      Parameters

      Returns Promise<{ finalId: string; parallelIds: string[] }>

    • Close the connection pool (only if using dedicated pool)

      Returns Promise<void>

    • Disconnect from the server (BullMQ v5 compatible). Alias for close().

      Returns Promise<void>

    • Get the result of a completed parent job (embedded only).

      Type Parameters

      • R = unknown

        Type of the job result

      Parameters

      • parentId: string

      Returns R | undefined

    • Get results from multiple parent jobs (embedded only).

      Type Parameters

      • R = unknown

        Type of the job results

      Parameters

      • parentIds: string[]

      Returns Map<string, R>

    • Wait until the FlowProducer is ready (BullMQ v5 compatible).

      Returns Promise<void>