nest: Alternating success/error with RabbitMQ: There is no equivalent message pattern defined in the remote service.
I’m submitting a…
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
When I used RabbitMQ with microservices, I get an alternating response/error “There is no equivalent message pattern defined in the remote service.”. One message will work, the next will not, and repeat. It always alternates, it is not randomly failing, it reliably fails and works, fails and works.
This does not happen with the other transports I’ve tried, NATS/REDIS
Expected behavior
This doesn’t happen.
Minimal reproduction of the problem with instructions
One nest app is a graphql server, followed by other nest apps all connected via microservices messaging with basic rabbitmq:3 docker container.
In graphql gateway I am using ClientProxyFactory to create a client with RMQ transport, to connect to the other services in the resolvers. Normally works but wanted to try RabbitMQ.
Repo that doesn’t reproduce (sadly) patricknazar/nestjs-rabbitmq-problem
What is the motivation / use case for changing the behavior?
It should work
Environment
Nest version: 5.4.0
For Tooling issues:
- Node version: 8
- Platform: Linux
Others:
Yarn
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 20 (2 by maintainers)
Hi @patricknazar From my investigation, RabbitMQ queue is routing by round-robin algorithm. @nestjs/microservice routed the message pattern until it reached to the service. Message Pattern didn’t route by RabbitMQ. If your microservice is listening to the same queue and didn’t implement MessagePattern for all service, then you will get that issue. So my suggestion, you can group MessagePattern for each queue and listen to services used that queue. For example:
BTW, Current @nestjs/miscroservice supports listen with multiple queues (will be multiple connection).
Hi @kamilmysliwiec , Can @nestjs/miscroservice support multiple queue for same connection. For example: app.connectMicroservice({ transport: Transport.RMQ, options: { urls: [
amqp://rabbitmq:5672], queues: [ ‘queue_1’, ‘queue_2’ ], queueOptions: { durable: false, }, }, });I found the problem in my code (the pattern object in my second call was wrong), and now everything works