Processor
The Processor interface represents a job processor that can process jobs from the queue, either in the background or synchronously.
Creating a processor
Create a processor by calling createProcessor on the queue.
const jobQueue = getJobQueue();
const processor = queue.createProcessor(handlers, options);ProcessorOptions
interface ProcessorOptions {
workerId?: string;
batchSize?: number;
concurrency?: number;
pollInterval?: number;
onError?: (error: Error) => void;
verbose?: boolean;
jobType?: string | string[];
}Methods
startInBackground
startInBackground(): voidStart the job processor in the background. This will run continuously and process jobs as they become available. It polls for new jobs every pollInterval milliseconds (default: 5 seconds).
stop
stop(): voidStop the job processor that runs in the background.
isRunning
isRunning(): booleanCheck if the job processor is running.
start
start(): Promise<number>Start the job processor synchronously. This will process jobs immediately and then stop. Returns the number of jobs processed.