diff --git a/src/allowance/services/allowance-worker.service.ts b/src/allowance/services/allowance-worker.service.ts index 03d1f4b..b7326e2 100644 --- a/src/allowance/services/allowance-worker.service.ts +++ b/src/allowance/services/allowance-worker.service.ts @@ -5,7 +5,7 @@ import moment from 'moment'; import { CardService } from '~/card/services'; import { AllowanceScheduleRepository } from '../repositories/allowance-schedule.repository'; import { AllowanceCreditRepository } from '../repositories/allowance-credit.repository'; -import { ALLOWANCE_DLQ_EXCHANGE, ALLOWANCE_QUEUE_NAME } from '../constants'; +import { ALLOWANCE_DLQ_EXCHANGE, ALLOWANCE_QUEUE_NAME, ALLOWANCE_RETRY_EXCHANGE } from '../constants'; import { AllowanceFrequency, AllowanceScheduleStatus } from '../enums'; type AllowanceQueuePayload = { @@ -53,7 +53,11 @@ export class AllowanceWorkerService implements OnModuleInit, OnModuleDestroy { }); this.channel = this.connection.createChannel({ setup: async (channel: any) => { - await channel.assertQueue(this.queueName, { durable: true }); + await channel.assertQueue(this.queueName, { + durable: true, + deadLetterExchange: ALLOWANCE_RETRY_EXCHANGE, + deadLetterRoutingKey: this.queueName, + }); await channel.prefetch(10); await channel.consume(this.queueName, (msg: any) => this.handleMessage(channel, msg), { noAck: false,