nestjs icon indicating copy to clipboard operation
nestjs copied to clipboard

Share rabbitmq connection between lib and microservice

Open Hatgor opened this issue 3 years ago • 1 comments

Hello guys!

Need your advice about syntax and functionality. I've created a RabbitMQ NestJS lib as a wrapper over your lib in my NestJS monorepo project, to import it as a module to other apps to allow them send messages via lib methods. But regarding receiving messages I still need to import your lib directly to the app module. So for now if microservice need both send and receive messages, it connects to rabbitmq twice - via lib and via direct import.

So my main question is - can I make imported lib somehow "share" it's connection with target module, to let him using @RabbitSubscribe freely?

And if it is possible, how should I make it? Is it possible to specify exhangers while importing lib? It feels like it can be done dy NestJS Dynamic modules, but I have no idea how it should be done exactly.

Thanks in advance!

Hatgor avatar Jul 12 '22 11:07 Hatgor

Do you mean you've implemented your own CustomModule with RabbitMQModule in it?

kzeratal avatar Jul 28 '22 09:07 kzeratal