I am trying to create multiple queues in NestJs, the documentation says that:
Create multiple queues by passing multiple comma-separated configuration objects to the registerQueue() method.
But this is not working for me, because when I try to do so, VScode suggests me that I should be mentioning Bull option here, after the comma. Below is my configuration for a single queue, how do I register multiple queues?
@Module({
imports: [
ConfigModule,
BullModule.registerQueueAsync({
name: 'Queue1',
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
redis: {
host: configService.get('QUEUE_HOST'),
port: +configService.get('QUEUE_PORT'),
},
}),
inject: [ConfigService],
}),
HttpModule,
],
controllers: [ScheduleController],
providers: [MainConsumer], //Service is included here
})
export class AppModule {}
Both the methods registerQueue and registerQueueAsync receive comma separated values as arguments in the met
As NestJS site states:
Create multiple queues by passing multiple comma-separated configuration objects to the registerQueue() method.
So, basically you have to do the following thing to solve the issue.
@Module({ imports: [ ConfigModule, BullModule.registerQueueAsync({ name: 'Queue1', imports: [ConfigModule], useFactory: async (configService: ConfigService) => ({ redis: { host: configService.get('QUEUE_HOST'), port: +configService.get('QUEUE_PORT'), }, }), inject: [ConfigService], }, { name: 'Queue2', imports: [ConfigModule], useFactory: async (configService: ConfigService) => ({ redis: { host: configService.get('QUEUE_HOST'), port: +configService.get('QUEUE_PORT'), }, }), inject: [ConfigService], }), HttpModule, ], controllers: [ScheduleController], providers: [MainConsumer], //Service is included here }) export class AppModule {}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.