Refactor payment processing services to use CreatePaymentDto and simplify job handling
This commit is contained in:
parent
96b1e8cd80
commit
5d268e8a5d
@ -4,24 +4,20 @@ import { Queue } from 'bullmq';
|
||||
import { CreatePaymentDto } from '../payments/dto/create-payment.dto';
|
||||
import { PAYMENT_QUEUE } from './constants/queue.constants';
|
||||
|
||||
export interface PaymentJobData {
|
||||
paymentData: CreatePaymentDto;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class QueueService {
|
||||
constructor(@InjectQueue(PAYMENT_QUEUE) private paymentQueue: Queue) {}
|
||||
|
||||
async addPaymentJob(data: PaymentJobData): Promise<void> {
|
||||
async addPaymentJob(data: CreatePaymentDto): Promise<void> {
|
||||
await this.paymentQueue.add(PAYMENT_QUEUE, data, {
|
||||
attempts: 2,
|
||||
jobId: data.correlationId,
|
||||
attempts: 5,
|
||||
backoff: {
|
||||
type: 'exponential',
|
||||
delay: 2000,
|
||||
},
|
||||
removeOnComplete: 3,
|
||||
removeOnFail: 2,
|
||||
removeOnComplete: 100,
|
||||
removeOnFail: 50,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user