nestjs icon indicating copy to clipboard operation
nestjs copied to clipboard

RabbitMQ AmqpConnection access from child module

Open m-romandic-un1 opened this issue 1 year ago • 1 comments

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?

m-romandic-un1 avatar Mar 07 '24 10:03 m-romandic-un1

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.

Ziao avatar Aug 05 '24 15:08 Ziao

@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

underfisk avatar Sep 26 '24 12:09 underfisk