question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Having trouble consuming messages via subscription (nestjs-rabbitmq)

See original GitHub issue

Hello, 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

Screen Shot 2021-07-30 at 12 00 05 PM Screen Shot 2021-07-30 at 12 06 49 PM

App bootstrap

Screen Shot 2021-07-30 at 11 58 09 AM

Publishing a message, but subscription handler is not invoking

Screen Shot 2021-07-30 at 12 13 13 PM

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
WonderPandacommented, Aug 9, 2021

@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

1reaction
collinwucommented, Aug 7, 2021

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 for isRabbitContext(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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found