I try to implement Bull queue in Typescript and NestJS, my code:
@Injectable()
export class MailService {
constructor(
@InjectQueue('mail')
private readonly mailQueue: Queue
) {}
async addToQueue(): Promise<void> {
this.mailQueue.add(() => {
return this.sendMail();
})
}
async sendMail(): Promise<void> {
//logic to implement
this.addToQueue();
}
}
fast question: Is this implementation sufficient for my job queuing to work?, If not: what i must to do?