nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.69k stars 7.63k forks source link

RMQ Every other request responds "There is no matching message handler defined in the remote service." #8887

Closed raikasdev closed 2 years ago

raikasdev commented 2 years ago

Is there an existing issue for this?

Current behavior

Currently every other request works, and every other is being marked as "Unroutable (drop)" by RabbitMQ and responding with "There is no matching message handler defined in the remote service.".

Minimum reproduction code

https://github.com/rittaschool/ritta-server

Steps to reproduce

  1. ./update.sh
  2. docker-compose -f docker-compose.dev.yml up
  3. http://localhost:15672 -> guest:guest
  4. Create new users: users:users and auth:auth
  5. Restart (CTRL+C old process, run step 2)
  6. http://localhost:3000/docs
  7. /api/v1/users
  8. Run twice

Expected behavior

The list of users should be sent every time.

Package

Other package

No response

NestJS version

8.2.4

Packages versions

[System Information]
OS Version     : Linux 5.15
NodeJS Version : v16.13.1
YARN Version    : 3.0.2 

[Nest CLI]
Nest CLI Version : 8.1.6 

[Nest Platform Information]
platform-express version : 8.2.4
platform-fastify version : 8.2.4
microservices version    : 8.2.4
schematics version       : 8.0.5
graphql version          : 9.1.2
swagger version          : 5.1.5
testing version          : 8.2.4
common version           : 8.2.4
config version           : 1.1.6
core version             : 8.2.4
cli version              : 8.1.6

Node.js version

16.13.1

In which operating systems have you tested?

Other

Authentication part of the application works fine without this problem. I am pretty sure that the problem lies somewhere inside the apps/users part of the repository.

raikasdev commented 2 years ago

I found the answer from the Discord server!

The solution was to create a own queue for every microservice (and and a own event bus). https://github.com/rittaschool/ritta-server/commit/b837fd9f73a3d1163c02c2b5aef6102c5acb2334

amhoba2014 commented 2 years ago

I found the answer from the Discord server!

The solution was to create a own queue for every microservice (and and a own event bus). rittaschool/ritta@b837fd9

Would you please elaborate on this? What do you mean by event bus?

raikasdev commented 2 years ago

Client proxies, like here: https://github.com/rittaschool/ritta/blob/b837fd9f73a3d1163c02c2b5aef6102c5acb2334/apps/auth/src/main.ts#L29

amhoba2014 commented 2 years ago

Client proxies, like here: https://github.com/rittaschool/ritta/blob/b837fd9f73a3d1163c02c2b5aef6102c5acb2334/apps/auth/src/main.ts#L29

Thanks for your reply, I actually created a reproducable repository for my problem https://github.com/jtutxtiiddtieitxiexutusetu/to-demonstrate-the-error-nestjs-rabbitmq-microservice

Would you please test it and find where the problem is? I have spent quite some time but have not been able to find the source of problem. Events are being sent but I keep getting There is no matching event handler defined in the remote service. Event pattern: one_sent for no reason.

I can ignore this error, yes, but I might predict that future inconsistencies may arise!

Thanks for your help.

amhoba2014 commented 2 years ago

I found the answer from the Discord server!

The solution was to create a own queue for every microservice (and and a own event bus). rittaschool/ritta@b837fd9

If every microservice has its own queue then how are they able to emit events to each other? There is no documentation on event bus in Nest.js unfortunately....

amhoba2014 commented 2 years ago

I've even tested the entire test codebase ( https://github.com/jtutxtiiddtieitxiexutusetu/to-demonstrate-the-error-nestjs-rabbitmq-microservice ) on the chaifeng/ubuntu-22.04-docker-20.10.17 vagrant box (I suspected my ubuntu is faulty), and the problem still persists!

kamilmysliwiec commented 2 years ago

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.