golevelup / nestjs

A collection of badass modules and utilities to help you level up your NestJS applications 🚀
MIT License
2.29k stars 264 forks source link

RabbitMQ AmqpConnection access from child module #708

Closed m-romandic-un1 closed 1 month ago

m-romandic-un1 commented 8 months ago

RabbitMQ gets registered on root module level, but when I want to Inject AmqpConnection in other module for publish/request purposes it says that I cannot access it. Why RabbitMQ is not global, how to achieve it?

Ziao commented 3 months ago

Same issue here. Seems a little counterintuitive, especially since there's only a .forRoot() on the module and not a forModule or similar. How do we accomplish this? I would think it's a very common requirement.

underfisk commented 1 month ago

@m-romandic-un1 You can create a global module by adding @Global decorator which will be imported across your library. If not, you can make sure that your module (re)-exports the RabbitMQ module and so when any consumer attempts to import your module, the RabbitMQ will be exported. LMK if that works for you

@Ziao We don't offer .forFeature, that could be a potential enhancement