#NestJS lifecicles in cqrs and bullmq module.

4 messages · Page 1 of 1 (latest)

mortal fractal
#

Hello,

In my company/team, we are having troubles with the hooks, since bullmq uses onModuleInit for everything, we decided to say onModuleInit is the only hook we should use, since the bullmq starts tasks and this means, everything should be ready for bullmq start tasks, but then we have the cqrs module in another project, in which register all the event-handlers/command-handles onApplicationBootstrap, making it impossible to connect cqrs with bullmq directly. since bullmq starts doing stuff before cqrs is able to handle data. Is there a reason why this is done this way?

It should not be like all consumers are initialized on moduleInit, and then the producers (everything that listens something) should be initialize onApplicationBootstrap?

Thanks,
Jaume.

rotund parrot
#

since bullmq uses onModuleInit for everything
Wait, is it really? Not even the database connection is ready onModuleInit, this must be a mistake 🤔

mortal fractal
rotund parrot
#

@mortal fractal I found this issue, it will probably solve your problem, too. https://github.com/nestjs/bull/issues/1664
In your position, I would probably add a comment to the issue explaining your use-case. I believe that since bull connects to an external system, it should not do so while the DI tree is still resolving.

GitHub

Is there an existing issue that is already proposing this? I have searched the existing issues Is your feature request related to a problem? Please describe it I notice that workers on the @nestjs/...