Having trouble consuming messages via subscription (nestjs-rabbitmq)
See original GitHub issueHello, I’m having trouble leveraging @golevelup/nestjs-rabbitmq package and I’m not sure what I’m missing.
I’ve been following the docs wiring up the message queue to a NestJS application, but I’m publishing messages via the RabbitMQ admin client, but not getting any messages showing up via subscription handler.
Screenshots below:
Messaging Service / Module


App bootstrap

Publishing a message, but subscription handler is not invoking

Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
RabbitMQ - Microservices - A progressive Node.js framework
RabbitMQ is an open-source and lightweight message broker which supports multiple messaging protocols. It can be deployed in distributed and federated ...
Read more >Handling Long Processes using Nest.JS and RabbitMQ
A article on how I handle long processes using Nest.JS and RabbitMQ. This contains a tutorial on how to implement the consumer and...
Read more >Programatically declare RabbitMQ consumers in NestJS ...
Each message can be processed no matter the order, so I'm wondering what would be the best practise to declare new consumers for...
Read more >API with NestJS #19. Using RabbitMQ to communicate with ...
NestJS, has a broad selection of transporters that transmit messages across microservices and this article covers RabbitMQ.
Read more >Dead Lettering in Nest.js & RabbitMQ — Is it even possible?
The dead lettered messages are then forwarded to a dead letter exchange if one was specified. In our example, we'll simply forward them...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@collinwu Thanks for following up on this and writing up a detailed breakdown of how you solved the issue. In the future I will see about trying to add some kind of warning or logs that indicate that requests are being rejected due to interceptors
i figured out where and what went wrong in my scenario.
i suppose a combination of factors played into this, but for anyone that might be facing a similar issue, check your nestjs pipes, guards, interceptors.
debugging led me to inspect: https://github.com/golevelup/nestjs/blob/master/packages/rabbitmq/src/amqp/connection.ts#L430
I was able to log a silent error telling me that the request was unauthorized. That was really the clue I needed. This led me to refer back to RabbitMQ usage with interceptors as I have a global auth guard enabled, but didn’t immediately make the connection this might have been the culprit.
Changing my global auth guard to return
true
forisRabbitContext(context)
fixed the issue with the subscription handler not firing on messages. Now this library works as intended.But having this issue led me to try to fill in some gaps in my knowledge about Nestjs in general. The FAQ section is where I started to understand how the Request Lifecycle works in Nest and other important concepts such as Hybrid Application which is what we’re shooting for in our use case.
Hope this helps another person who might have this issue in the future