JobQueueWorker class
The consuming end of a job queue: handles jobs and never pushes them.
Use this in the processes that do the work, paired with a JobQueuePublisher constructed with the same JobQueueOptions.name. Run as many as you like — each job goes to one of them, which is how this scales out. It opens a worker-mode connection only, so it cannot enqueue jobs even by accident.
Signature:
export declare class JobQueueWorker<T> extends BaseJobQueue<JobQueueWorker<T>, T> implements AnyJobQueueWorker<JobQueueWorker<T>, T>
Extends: BaseJobQueue<JobQueueWorker<T>, T>
Implements: AnyJobQueueWorker<JobQueueWorker<T>, T>
Example
import { JobQueueWorker } from '@imqueue/job';
const worker = new JobQueueWorker<Email>({ name: 'Email' });
worker.onPop(async (email: Email) => {
await send(email);
});
await worker.start();
Constructors
|
Constructor |
Modifiers |
Description |
|---|---|---|
|
Creates a worker-mode queue over the named job queue. |
Methods
|
Method |
Modifiers |
Description |
|---|---|---|
|
Registers the handler called for each job popped from this queue. |
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.