Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 9x 1x 1x | import { Injectable } from '@nestjs/common'
import { InjectQueue } from '@nestjs/bullmq'
import { Queue } from 'bullmq'
import { SendReceiptJobData } from '../interfaces/email-jobs.interface'
@Injectable()
export class EmailProducer {
constructor(@InjectQueue('email') private emailQueue: Queue) {}
async sendReceipt(email: string, amount: number, transactionId: string, eventSlug: string) {
const jobData: SendReceiptJobData = {
email,
amount,
transactionId,
eventSlug,
date: new Date(),
}
await this.emailQueue.add('send-receipt', jobData, {
attempts: 3, // Retry failed emails 3 times
backoff: {
type: 'exponential',
delay: 1000,
},
})
}
}
|