Increase payment processor concurrency and add error logging

This commit is contained in:
Jose Eduardo 2025-08-17 04:30:34 -04:00
parent 8ab96b8292
commit b7ebc29af4

View File

@ -8,7 +8,7 @@ import { Payment } from '../entities/payment.entity';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
import { CreatePaymentDto } from '../dto/create-payment.dto'; import { CreatePaymentDto } from '../dto/create-payment.dto';
@Processor(PAYMENT_QUEUE, { concurrency: 2 }) @Processor(PAYMENT_QUEUE, { concurrency: 20 })
@Injectable() @Injectable()
export class PaymentProcessor extends WorkerHost { export class PaymentProcessor extends WorkerHost {
private readonly logger = new Logger(PaymentProcessor.name); private readonly logger = new Logger(PaymentProcessor.name);
@ -27,6 +27,13 @@ export class PaymentProcessor extends WorkerHost {
where: { correlationId: payment.correlationId }, where: { correlationId: payment.correlationId },
}); });
if (!exists) await this.processPaymentService.execute(payment); if (!exists) {
try {
await this.processPaymentService.execute(payment);
} catch (error) {
this.logger.error(`Error processing payment: ${error.message}`);
throw error;
}
}
} }
} }