I am following doc to start to use queue. I installed @nestjs/bull
, bull
, @types/bull
dependencies. And here is my app.module.ts
:
@Module({
imports: [
ConfigModule.forRoot({
load: [configuration],
}),
BullModule.registerQueue({
name: 'create_checkin',
redis: {
host: 'localhost',
port: 6379,
},
}),
EventModule,
],
})
export class AppModule {}
I imported BullModule in root module. And here is my event.service.ts
:
@Injectable()
export class EventService {
constructor(
@InjectQueue('create_checkin') private readonly createCheckinQueue: Queue,
) {
}
}
And when I start server, I got the following error message:
Nest can't resolve dependencies of the EventService
Please make sure that the argument BullQueue_create_checkin at index [0] is available in the EventModule context.
I don’t know which step I did wrong. Someone can help me?
5
Answers
Make sure you are placing EventService under providers array in EventModule.
Try importing BullModule straight in Event Module – I had the same problem and doing it this way make it work.
I know that it’s async method, but maybe you should try.
You have to import bull module inside the module you are trying to setup queue. You can also refer https://medium.com/@shikhar01.cse14/bull-queues-in-nestjs-306c51cb0ec2
Had a similar problem, in my case it was enough to add the
BullModule
to theexports
array in order to successfully run the whole project. Like this:Then in my service I’ve been able to inject the queue:
You can do like below