Version: Next

Job Events

This package provides few in-built events out of the box, which you can use to manage the queues objectively and decisively.

Events

info

All the decorators must be used inside an Injectable provider only.

OnJobFailed

Use this decorator to receive update when any job fails.

import { Injectable } from '@nestjs/common';
import { OnJobFailed } from '@lib/queue';
@Injectable()
export class QueueEvents {
@OnJobFailed()
async onJobFailed(job: Object) {
console.log('-- job failed --');
// ... your logic here
}
}

OnJobProcessing

Use this decorator to receive update when any job starts processing.

import { Injectable } from '@nestjs/common';
import { OnJobProcessing } from '@lib/queue';
@Injectable()
export class QueueEvents {
@OnJobProcessing()
async onJobProcessing(job: Object) {
console.log('-- job processing --');
// ... your logic here
}
}

OnJobProcessed

Use this decorator to receive update when any job is succesfully processed.

import { Injectable } from '@nestjs/common';
import { OnJobProcessed } from '@lib/queue';
@Injectable()
export class QueueEvents {
@OnJobProcessed()
async onJobProcessed(job: Object) {
console.log('-- job processed --');
// ... your logic here
}
}