@ssdev-toolkit/nestjs-queue
v1.0.0
Published
BullMQ job dispatch and worker handlers. Feature modules enqueue via `QueueFacade` and implement `@QueueHandler`.
Downloads
97
Readme
@ssdev-toolkit/nestjs-queue
BullMQ job dispatch and worker handlers. Feature modules enqueue via QueueFacade and implement @QueueHandler.
Install
npm install @ssdev-toolkit/nestjs-core @ssdev-toolkit/nestjs-queueRequires Redis (BullMQ) and typically AuthModule for worker identity context.
What it does
QueueModule.forRoot/forRootAsyncQueueFacade— enqueue typed job classes@QueueHandler(JobClass, options)— worker (includes@Injectable())- Typed job errors (
TransientJobError,PermanentJobError, …) andisRetryableError - Optional job-log store (
IQueueJobRepository); Redis and null implementations shipped
Do not inject IQueueJobRepository from feature modules; dispatch through the facade.
Usage
@QueueHandler(CorrespondenceDispatchJob, {
attempts: 3,
backoff: { type: 'exponential', delay: 5000 },
})
export class CorrespondenceDispatchHandler
implements IQueueHandler<CorrespondenceDispatchJob>
{
async execute(job: Job<CorrespondenceDispatchJob>, ctx: JobExecutionContext) {
// throw TransientJobError to retry
}
}await this.queueFacade.add(new CorrespondenceDispatchJob(/* … */));Build (this repo)
npm run build -w @ssdev-toolkit/nestjs-queueOverview: root README.
