fix: Added bullmq
This commit is contained in:
18
src/mail/mail.consumer.ts
Normal file
18
src/mail/mail.consumer.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Processor, WorkerHost } from "@nestjs/bullmq";
|
||||
import { Job } from "bullmq";
|
||||
import { MailService } from "./mail.service";
|
||||
|
||||
@Processor('mail')
|
||||
export class MailConsumer extends WorkerHost {
|
||||
constructor(private readonly mailService: MailService) {
|
||||
super()
|
||||
}
|
||||
|
||||
async process(job: Job<{ email: string }>) {
|
||||
switch (job.name) {
|
||||
case 'send-welcome-email':
|
||||
await this.mailService.sendWelcomeMail({ to: job.data.email })
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user