Currently, I am in the process of developing an application with BullMQ and NestJS. Everything seems to be working smoothly, but there is a particular issue that is bothering me.
Whenever I register a new queue within my application, I typically follow this approach:
@Module({
imports: [
BullModule.registerQueueAsync({
name: 'email-queue',
}),
],
controllers: [EmailController],
providers: [ ],
})
Subsequently, when utilizing it within a NestJS service, my code would look something like this:
@Injectable()
export class WhatsappQueueService {
constructor(
@InjectQueue('email-queue') private queue: Queue,
) {}
async addMessage(dtoSendMessage: any) {
const included = await this.queue.add(
'send-message',
dtoSendMessage,
);
return included;
}
}
The dilemma arises when I attempt to create a constant with the value 'email-queue', export it from the service, and incorporate it into the Module definition. This way, manual management of queue names can be avoided.
However, upon using the constant, an error is triggered indicating that NestJS is unable to locate the Queue. I suspect this issue is related to the @InjectQueue() decorator.
Is there a means by which constants can be utilized for naming queues?